Python Program to Convert Kilometers to Miles

By | October 3, 2021
Python Program to Convert Kilometers to Miles

In this article, we have provided a python program which is capable of converting kilometers in miles.

Prerequisite topics to create this program.

  • Python Input, Output
  • Python Data types
  • Python Operators


  • First, we ask the user the value in Kilometres
  • Then we convert that into miles by multiplying the entered number with 0.621371, because there are 0.621371 miles in 1 kilometer.
  • At last, using the print function we will print the value of miles.


kilometers = float(input("Enter value in kilometers: "))
miles = kilometers *  0.621371
print("There are {0:.2f} Miles in {1:.2f} Kms ".format(miles,kilometers))


Enter value in kilometers: 250
There are 155.34 Miles in 250.00 Kms

Behind the Code

In this above example we ask the user to enter the value of Kilometers, and using the float() function we convert the user input from string to floating data type.


Then we multiply the value entered by the user by 0.621371 and get the value of miles.

People are also reading:

Leave a Reply

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