Python Program to Convert Kilometers to Miles

To understand this example, you should have the knowledge of the following Python programming topics:


Example: Kilometers to Miles

Output

Enter value in kilometers: 3.5
3.50 kilometers is equal to 2.17 miles

Here, the user is asked to enter kilometers. This value is stored in the kilometers variable.

Since 1 kilometer is equal to 0.621371 miles, we can get the equivalent miles by multiplying kilometers with this factor.

Your turn: Modify the above program to convert miles to kilometers using the following formula and run it.

kilometers = miles / conv_fac