Python Program to Convert Kilometers to Miles – 2024

Hey guys, in this blog we will see a Python Program to Convert Kilometers to Miles.

Code

# Python Program to Convert Kilometers to Miles

# Taking kilometers input from the user
kilometers = float(input("Enter the distance in kilometers -> "))

# conversion factor
conversion_factor = 0.621371

# calculate miles
miles = kilometers * conversion_factor
print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))

Output

Enter the distance in kilometers -> 12
12.00 kilometers is equal to 7.46 miles
Enter the distance in kilometers -> 10
10.00 kilometers is equal to 6.21 miles
Enter the distance in kilometers -> 1
1.00 kilometers is equal to 0.62 miles

We are simply converting Kilometers to Miles using a conversion factor which is 0.621371.

I Kilometer = 0.621371 Miles

Check out our other python programming examples

Leave a Reply

Your email address will not be published. Required fields are marked *