Python Program - Convert Kilometers to Miles

www‮‬.theitroad.com

To convert kilometers to miles in Python, you can use the following formula:

miles = kilometers * 0.621371

Here's a program that uses this formula to convert kilometers to miles:

kilometers = float(input("Enter value in kilometers: "))

# convert kilometers to miles
miles = kilometers * 0.621371

print("{0} kilometers is equal to {1} miles".format(kilometers, miles))

In this program, the user is prompted to enter a value in kilometers. The float function is used to convert the input value to a floating-point number. Then, the value is multiplied by 0.621371 to convert it to miles. The result is then printed to the console.

When you run this program, it will prompt you to enter a value in kilometers. After you enter a value and press Enter, the program will convert the value to miles and print the result to the console.