def km_to_miles(): number = raw_input("Enter Kilometers \n> ") if number == "exit" or number == "done": import project2 project2.whatyouwant() elif number == "back": miles_km() else: result = float(number) * 0.62 print "\n%s kilometers is equal to %s miles.\n" % (str(number), str(result)) km_to_miles()
def currency(): print "Enter '1' for USD to TWD, or '2' for TWD to USD" input = raw_input("> ").lower() if input == "1": print "Type a number to convert \n'back' goes to previous menu \n'done' goes to root menu" print "-" * 10 usd_to_twd() elif input == "2": print "Type a number to convert \n'back' goes to previous menu \n'done' goes to root menu" print "-" * 10 twd_to_usd() elif input == "done" or input == "exit": import project2 project2.whatyouwant() else: print "\nSay '1', '2', or 'done'\n" currency()
def miles_km(): print "Enter '1' for mi to km, or '2' for km to mi" input = raw_input("> ").lower() if input == "1": print "Type a number to convert \n'back' goes to previous menu \n'done' goes to root menu" print "-" * 10 miles_to_km() elif input == "2": print "Type a number to convert \n'back' goes to previous menu \n'done' goes to root menu" print "-" * 10 km_to_miles() elif input == "done" or input == "exit": import project2 project2.whatyouwant() else: print "\nSay '1', '2', or 'done'\n" miles_km()
def twd_to_usd(): print "Enter TWD amount" number = raw_input("> ") if number == "done" or number == "exit": import project2 project2.whatyouwant() elif number == "back": currency() else: try: x = float(number) if True: result = float(number) * 0.030 print "\nNT$%s is equal to US$%s\n" % (str(number), str(result)) twd_to_usd() except: print "Not a number, dummy!" twd_to_usd()