Python Program to Convert Kilometers to Miles


In [1]:
kilometers = float(input("Please enter distance in kilometers : "))

miles = kilometers * 0.621371

print("Distance in miles =", miles)
Please enter distance in kilometers : 5
Distance in miles = 3.106855

Here, we asked the user to input the distance in kilometers. One kilometer is equal to 0.621371 miles, so multiplied kilometers with 0.621371 and printed the distance in miles.