[Tutor] (no subject)
Pravya Reddy
pravyareddy at gmail.com
Mon Feb 11 16:56:36 CET 2013
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:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130211/24b376a7/attachment.html>
More information about the Tutor
mailing list