Can You Plaese help me with the code.

#converts temperature to fahrenheit or celsius

def print_options():
    print ("Options:")
    print (" 'p' print options")
    print (" 'c' convert from celsius")
    print (" 'f' convert from fahrenheit")
    print (" 'q' quit the program")

def celsius_to_fahrenheit(c_temp):
    return 9.0/5.0*c_temp+32

def fahrenheit_to_celsius(f_temp):
    return (f_temp - 32.0)*5.0/9.0

choice = "p"
while choice != "q":
    if choice == "c":
        temp = input(input("Celsius temperature:"))
        print ("Fahrenheit:",celsius_to_fahrenheit(temp))
    elif choice == "f":
        temp = input("Fahrenheit temperature:")
        print ("Celsius:",fahrenheit_to_celsius(temp))
    elif choice != "q":
        print_options()
    choice = input(input("option:"))

The Output i got is:
Options:
 'p' print options
 'c' convert from celsius
 'f' convert from fahrenheit
 'q' quit the program
option:c
c
Options:
 'p' print options
 'c' convert from celsius
 'f' convert from fahrenheit
 'q' quit the program
option:
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to