To convert kilometres to miles in python, you have to ask from user to enter the value of distance in kilometre to convert that distance into miles as shown here in the program given below.
Following python program ask from user to enter distance in kilometre to find the equivalent distance in mile:
# Python Program - Convert Kilometres to Miles while True: print("Enter 'x' for exit.") km = input("Enter total kilometres: ") if km == 'x': break else: kilometres = float(km) conversion_factor = 0.621371 miles = kilometres * conversion_factor print("%0.2f Kilometres = %0.2f Miles.\n" %(kilometres,miles))
Here is the sample run of the above Python program demonstrating how to convert distance from kilometre to miles: