Home >>Python Programs >Python program to convert kilometers to miles
In this example, we are going to see the python program to convert kilometers to miles. The kilometer is a unit of length in the metric system.1 kilometer is equal to 1000 meters. Mile is also the unit of length. 1 mile is equal to 1760 yards.
Miles = kilometer * 0.62137 Kilometer = Miles / 0.62137Example 1:
# Collect input from the user
kilometers = float(input('How many kilometers?: '))
# conversion factor
conv_fac = 0.621371
# calculate miles
miles = kilometers * conv_fac
print('%0.3f kilometers is equal to %0.3f miles' %(kilometers,miles))
# Collect input from the user
kilometers = float(input('How many kilometers?: '))
# conversion factor
conv_fac = 0.621371
# calculate miles
miles = kilometers * conv_fac
print('%0.3f kilometers is equal to %0.3f miles' %(kilometers,miles))