Type Casting vs Type Coercion in Python

The process of converting the value of one data type (integer, string, float, etc.) to another data type is called Type conversion. Python has two types of type conversion.

  • Implicit Type Conversion

  • Explicit Type Conversion

When we have done explicit conversion of a value from one data type to another, this is know as Typecasting. However, in most of the programming language including python, there is an implicit conversion of data types during compilation or during run time. This is known as Type Coercion.

For an example, in an expression that has integer and floating point numbers (like 21+2.1=23.1) the compiler will automatically convert the integer into floating point number so that fractional part is not lost .

Don’t know what is indentation in Python? Read: What is indentation in Python
You Missed