0

The temp converter should do exactly as assumed, f to c, or c to f.

It works from f to c (except negatives don't show up?), but it doesn't work when converting from c to f.

print "Temperature Converter"
temp = 0

def user_temp():
  temp = raw_input("Enter a temperature: ")
  return float(temp)


def convert():
   conv = raw_input("Convert to (F)ahrenheit or (C)elsius? ")
   if conv.lower() == "f":
    new_temp = (9 / 5) * (temp + 32)
    print new_temp
    user_temp()
  elif conv.lower() == "c":
    new_temp = (5 / 9) * (temp - (32))
    print new_temp
    user_temp()

user_temp()
convert()

The user_temp() within the if/elif is simply so I could continually test numbers, not to annoy users with an infinite loop.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Charles Watson
  • 1,065
  • 2
  • 16
  • 39

0 Answers0