python - NameError: name 'C' is not defined` error Converting Temperature -


i'm working on python code convert fahrenheit celsius , second code converts celsius fahrenheit. wrote each code same way, using (if/else) whenever try make first condition true. example, when temperature f = -400 nameerror: name 'c' not defined error.

i tried changed line position c runs before last print line. still no luck. second code part converts c f runs without error. tried putting equation c after last print line still same error.

is may missing on first part may preventing me making first condition true?

i'm running python 2.7.10 , using terminal on mac os x el capitan (10.11)

convert fahrenheit celsius:

f = int(raw_input("enter temperature in fahrenheit:"))   if f >= (-459.67):      print "temperature in absolute 0 cannot achieved"  else:       c = f - 32 * (0.555556)  print "the temperature %.1f" 'c'  % c  

convert celsius fahrenheit:

c = int(raw_input("enter temperature in celsius:"))  if c <= (-273.15):         print "temperature in absolute 0 cannot achieved"   else:                                                              print "the temperature %.1f" 'f' % f                  f = c * (1.8) + 32   

as people said, there many errors. 1 solution is:

f = float(raw_input("enter temperature in fahrenheit:")) if f <= (-459.67):     print "temperature in absolute 0 cannot achieved" else:     c = f - 32 * (0.555556)     print "the temperature %.1f" 'c'  % c  # ----------------------------------------------------------  c = float(raw_input("enter temperature in celsius:")) if c <= (-273.15):     print "temperature in absolute 0 cannot achieved" else:     f = c * (1.8) + 32     print "the temperature %.1f" 'f' % f 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -