input() is a very convenient function, but there is one catch: user input is always treated as a string value, even if a number is provided. If you ask for a number with
input() and then try to add it to another number, Python will throw an error.
Luckily, we can use functions that convert between data types:
x into a string,
x into an integer,
x into a floating point number.
Here is a simple program that converts kilometers to miles:
distance_kilometers = input('How many kilometers have you driven? ')
distance_miles = float(distance_kilometers) // 1.60934
print('This means you have driven', distance_miles, 'miles!')
float(distance_kilometers) converts user input into a number of the
float type. Without this conversion, we wouldn't be able to calculate