Change the type of the variable from one type to another type. When you want to specify a type to a variable you can use casting.
- int() - The conversion of a float number to a whole number happens, removing the decimal values. Also the string gets converted to a whole number.
- float() - The conversion of a integer number to a float number by adding appropriate decimal values. Also the string gets converted to a floating point number.
- str() - The conversion of both the integer and floating point numbers to a string occurs when the str() is used.
Example
y = float(302)
z = int(3.14)
a = str(34)
here in the above examples, the value of 302 is casted as float. The value of 3.14 is casted as integer and the value of 34 is casted as a string which gives the value "34".