[Tutor] Please critique my temperature_conversion.py (original) (raw)
Dick Moores rdm at rcblue.com
Sun Jul 11 12:29:05 CEST 2004
- Previous message: [Tutor] Adding a search path PERMANENTLY?
- Next message: [Tutor] Please critique my temperature_conversion.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"""
temperature_conversion.py
temperature conversion of Fahrenheit <---> Celsius
from string import upper F_or_C = ""
while (F_or_C != "F" and F_or_C != "C"): t0 = raw_input("Enter temperature as 70F or 70 F or -12.47C: ") F_or_C = upper(t0[-1]) # store the F or C and ensure upper case t0 = t0[0:-1] # strip entered temp of the F or C t = t0 # get a string number to do the conversion calculation
if F_or_C == "F": t = 5/9. * (float(t) - 32) t = round(t,2) print (t0 + "F"), "is", (str(t) + "C") else: # i.e., F_or_C is "C" t = 9/5. * float(t) + 32 t = round(t,2) print (t0 + "C"), "is", (str(t) + "F") """
Thanks, tutors.
Dick Moores
- Previous message: [Tutor] Adding a search path PERMANENTLY?
- Next message: [Tutor] Please critique my temperature_conversion.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]