Skip to main content

Convert Kilometers to Miles in python

Simple 3 line python program to convert user input kilometer to miles

#Accept Distance in Kilometer 
#from km to miles need to divide appx  1.609344


km=float(input("\n\t Enter Kilometer to Convert it in miles: "))


#Now converting kilometer to Miles

miles=float((km/1.609344))

print("\n\t %f kilometer in Miles are %f "%(km,miles))

Output

	 Enter Kilometer to Convert it in miles: 3

	 3.000000 kilometer in Miles are 1.864114