;

# Python Program to Convert Kilometers to Miles and Miles to Kilometers

###### Tutorialsrack 22/04/2020 Python

In this Python program, we will learn how to convert kilometers to miles and miles to kilometers.

1 Kilometer = 0.621371 miles

For Converting Kilometers to Miles Formula is as

miles = kilometers * 0.621371

For Converting Miles to Kilometers  Formula is as

kilometers = miles / 0.621371

Here is the source code of the program to convert kilometers to miles and miles to kilometers.

##### Program 1: Convert Kilometers to Miles
``````# Python Program to Convert Kilometers to Miles

# Taking kilometers input from the user
kilometers = float(input("Enter value in kilometers: "))

# conversion factor
conv_fac = 0.621371

# calculate miles
miles = kilometers * conv_fac
print('\n%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
``````
##### Output

Enter value in kilometers: 5

5.00 kilometers is equal to 3.11 miles

##### Output
``````# Python Program to Convert Miles to Kilometers

# Taking kilometers input from the user
miles = float(input("\nEnter value in Miles: "))

# conversion factor
conv_fac = 0.621371

# calculate miles
kilometers = miles/conv_fac
print('\n%0.2f miles is equal to %0.2f kilometers' %(miles,kilometers))
``````
##### Output

Enter value in Miles: 5

5.00 miles is equal to 8.05 kilometers