Skip to content
Related Articles

Related Articles

Improve Article

Python Program to convert Kilometers to Miles

  • Difficulty Level : Expert
  • Last Updated : 19 Dec, 2017
Geek Week

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 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

Attention reader! All those who say programming isn’t for kids, just haven’t met the right mentors yet. Join the  Demo Class for First Step to Coding Coursespecifically designed for students of class 8 to 12. 

The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.

My Personal Notes arrow_drop_up
Recommended Articles
Page :