7. Typecasting
What is Type-Casting?
Functions used for Type-Casting
int(): Converting any Data Type to integer data type
float_var = 2.5
int_var = int(float_var)
print(int_var)
print(type(int_var))float(): Converting any Data Type to float data type
str(): Converting any Data Type to string data type
bool(): Converting any Data Type to boolean data type
Converting Zero Values to boolean gives False:
Converting Non Zero Values to boolean gives True:
Why do we use Type Casting ?
Last updated