In Python, we can convert one type of variable to another type. This conversion is called type casting or type conversion.
In casting, we convert variables declared in specific data types to the different data types.
Python performs the following two types of casting.
Implicit casting: The Python interpreter automatically performs an implicit type conversion, which avoids loss of data.
Explicit casting: The explicit type conversion is performed by the user using built-in functions.
To perform a type casting, we are going to use the following built-in functions:
- int(): convert any type variable to the integer type.