int(), float(), and str() are built-in conversion functions. Each creates a new value.
age = int("12")Line-by-line explanation
"12"begins as a string.int("12")creates the integer12.age =stores the new integer.
distance = float("2.5")Line-by-line explanation
"2.5"begins as text.float("2.5")creates the decimal number2.5.- The float is stored in
distance.
score_text = str(100)Line-by-line explanation
100begins as an integer.str(100)creates the string"100".- The string is stored in
score_text.
Conversion works only when the value makes sense. Python cannot turn "twelve" into an integer because those letters are not digits.