A Program to Convert Kilometers to Miles

In this example, we are giving a program to convert kilometers to miles.


Program to convert kilometers to miles:

  1. # Convert kilometers to miles
  2. km = float(input('Enter value in kilometers: '))
  3. convert_num = 0.621371
  4. miles = km * convert_num
  5. print('%0.2f kilometers is equal to %0.2f miles'%(km,miles))

Output:

Enter value in kilometers: 9
9.00 kilometers is equal to 5.59 miles