Typecasting in Python

Photo by Andrew Neel on Unsplash

Typecasting in Python

The conversion of one data type to another data type is known as type casting.

Python supports a wide variety of function or methods like int(), float(), str(), hex() etc

Two types of typecasting -

  1. Explicit conversion

  2. Implicit conversion

Explicit typecasting

The conversion of one data type to another data type, done via programmer as per the requirement is known as explicit typecasting.

Implicit typecasting

In Python, when the data type conversion takes place during compilation or during the run time, then it is known as implicit typecasting.