Python Program to Convert Kilometers to Miles
Convert Kilometers to Miles |
|
CODE | OUTPUT |
kilometers = 5.5
# To take kilometers from the user, uncomment the code below kilometers = input(“Enter value in 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)) |
5.500 kilometers is equal to 3.418 miles |
Note: To test the program, change the value of kilometers.
Modify the above program to convert miles to kilometers using the following formula and run it. kilometers = miles / conv_fac |