What is casting ?
Casting is when you convert one data type into another data type
convert Integer into Real
int_value = 10
real_value = float(int_value)
Output = 10.0
Convert Real into Integer
real_value = 10.4
int_value = int(real_value)
Output = 10
Convert String to Integer
int_str = “6”
int_value = int(int_str)
Output = 6
Convert Integer into String
value = 3
str_value = str(value)
Output = “3”
Convert Boolean into String
bool_value = True
str_value = str(bool_value)
Output = “True”
Convert String into Boolean
bool_str = “False”
bool_value = bool(bool_str)
Output = “False”