Saturday, April 9, 2016

Miles To Kilometers Converter in Python

In this simple program it will ask the user to give the distance in Miles and then our program will convert the given distance in miles into kilometers equivalent using Python as my programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

def my_program():
   print()
   print("MILES TO KILOMETERS CONVERTER")
   print()
   miles = float(input("How many miles? : "))
   print()
   kilometers = (miles * 1.60934)
   print('%0.2f Mile(s) is equal to %0.2f Kilometer(s).' %(miles,kilometers))
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()


No comments:

Post a Comment