Skip to content
Related Articles

Related Articles

Python Program to convert Kilometers to Miles

Improve Article
Save Article
  • Difficulty Level : Expert
  • Last Updated : 17 Jul, 2022
Improve Article
Save Article

Kilometer is a unit of length in the metric system equivalent to 1000 meters. Miles is also the unit of length equal to 1760 yards. Example:

Input: 5.5 
Output: 3.418 

Input: 6.5
Output: 4.039

Formula:

1 kilometer equals 0.62137 miles.
Miles = kilometer * 0.62137   
Kilometer = Miles / 0.62137

Python3




# Python3 program to convert
# kilometers to miles
 
# driver code
kilometers = 5.5
 
# conversion factor
conv = 0.621371
 
# calculate miles
miles = kilometers * conv
print('%0.3f kilometers is equal to %0.3f miles' %(kilometers,miles))
 
kilometers = 6.5
 
# calculate miles
miles = kilometers * conv
print('%0.3f kilometers is equal to %0.3f miles' %(kilometers,miles))

Output:

5.500 kilometers is equal to 3.418 miles
6.500 kilometers is equal to 4.039 miles

Time Complexity: O(1)

space complexity: O(1)

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!