Python – Kilometers to Miles

 

KILOMETERS TO MILES IN PYTHON

 

Program

 

# Python Program to convert kilometers to miles

 

# To take kilometers from the user

kilometers = float(input(“Enter the distance in kilometers: “))

 

# conversion factor

conv_fac = 0.621371

 

# calculate miles

miles = kilometers * conv_fac

 

print(‘%0.3f km is equal to %0.3f miles’ %(kilometers,miles))

 

input(“Press Enter to Exit”)

 

Output