Python Program to Convert Miles to Kilometers

In this python example, we'll learn to convert miles taken from user to kilometers and display it.

Python Source Code: Miles to Kilometers

# miles input from the user
miles = float(input("Enter value in miles: "))

# calculate kilometers and display
kilometers = miles * 1.60934
print('%0.3f miles is equal to %0.3f kilometers' %(miles, kilometers))


The output of the above program is:

Enter value in miles: 12
12.000 miles is equal to 19.312 kilometers