Source Code:
(back to article)
# Converting an integer to a floating-point number x = 10 y = float(x) print(y) # Converting a floating-point number to an integer x = 10.5 y = int(x) print(y) # Converting a string to an integer x = "10" y = int(x) print(y) # Converting a string to a floating-point number x = "10.5" y = float(x) print(y) # Converting an integer to a string x = 10 y = str(x) print(y) # Converting a floating-point number to a string x = 10.5 y = str(x) print(y)
Result:
Report an issue