Python 3 Program to Convert Kilometres to Miles

This Python programming tutorial will teach you a simple Python 3 program to convert kilometers to miles. Before moving ahead, make sure you know about basic Python programming concepts such as variables, data types, and operators. If you love books, check out these best books to learn Python programming.

Python 3 Program To Convert Kilometers to Miles

As you know, 1 KM is equal to 0.621371 Miles. Therefore, to convert kilometers to miles, you have to divide the number entered by a user by 1.609.

Here is the Python source code you can refer to:

#Python program to convert Kilometers to Miles
KM = float(input(print("Enter Kilometer = ")))
M = KM/1.60934
print("Miles = ", M)

Output

output - python program to convert kilometers to miles

Download Python File.

Python 3 Program to Convert Miles to Kilometers

1 mile is equal to 1.60934 KMs. Therefore, to convert miles to kilometers, you have to multiply the value by 1.60934.

Code:

def convertMilestoKm(value):
    value = value * 1.60934
    return value

MilesInput = float(input(print("Enter Miles: ")))
KM = convertMilestoKm(MilesInput)
print("Kilometers = ", KM)

Output:

Enter Miles: 2
Kilometers = 3.21868

Other Python programs for practice

  1. Python 3 Program To Add Two Matrices.
  2. Python 3 Program to Check Armstrong Number.
  3. Python 3 Program to Find the Sum of Natural Numbers.
  4. Python 3 Program To Find The Factorial Of A Number.
  5. Python 3 Program to Find Largest Among Three Numbers.
  6. Python 3 Program to Check Leap Year.
  7. Python 3 Program To Check If Number Is Positive Or Negative.
  8. Python 3 Program To Convert Celsius To Fahrenheit.
  9. Python 3 Program to Generate A Random Number.
  10. Python 3 Program To Swap Two Numbers.
  11. Python 3 Program To Solve A Quadratic Equation.
  12. Python 3 Program to Calculate The Area of a Triangle.
  13. Python 3 Program to Find the Square Root of A Number.
  14. Python 3 Program To Add Two Numbers.
  15. Python 3 Program to Print Hello World.

Scroll to Top