Learn about Python Program to Convert Miles to Kilometers in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Python Program to Convert Miles to Kilometers
# Program to convert miles to kilometers # input from user mile = float(input('Enter distance in miles: ')) # conversion factor basing on formula fac = 1.60934 # calculating kilometers from miles km = mile * fac # print result print('%0.2f miles is equal to %0.2f kilometers' %(mile, km))
Enter distance in miles: 3 3.00 miles is equal to 4.83 kilometers
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Convert Kilometers to Miles