In this tutorial we will see how to convert Kilometers to Miles in Python.
Kilometers to Miles Conversion in Python
This program prompts the user to enter the value in Kilometers and converts it into Miles by multiplying the entered value with 0.621371 (1 Km = 0.621371 mi.).
# Program published on https://beginnersbook.com # Program to convert Kilometers to Miles km = int(input("Enter the value in kilometers: ")) # 1 Kilometre = 0.621371 Mile ratio = 0.621371 # Converting km to mi. mi = km * ratio print("The entered value in Miles: ", mi)
Enter the value in kilometers: 10 The entered value in Miles: 6.21371