Math statements and Freeze problem

F. G. Brown fgbrown at ionet.net
Wed Jun 14 21:59:23 EDT 2000


Greetings
I haven't exactly hit a wall on this one, it's more like a thorn in my
side.I have two lines that figure conversion from Fahrenheit to Celsius and
vice versa.  Before I started writing this I was almost sure that I would
need only one line and the two conversions would both reference the same
line. But that hasn't been the case, as you can see below.  Was it just my
imagination or is there a more "elegant" way to do this? Also I tried to run
the Freeze program on this (first time) and something is not working right.
Does this have to be done at a DOS prompt or is it done in the python
shell,IDLE or PythonWin?
I think there is some kind of problem with my path statement, what does
yours look like?
Regards,
Fred


????????????????????????

# temp.py
         # description of program
print "The following program converts the values"
print "of Fahrenheit and Celsius. Select the known"
print "value you have below."
decide = 'y'
while decide == 'y':
         # selects known value to determine if or else statement
         print
         print "If the known temperature is in"
         print "degrees Fahrenheit enter (1) if"
         print "Celsius enter (2)"
         degrees = raw_input("Fahrenheit (1) or Celsius (2)?   ")
         if degrees == "1":
              fahrenheit = input (" What is the temperature in degrees
Fahrenheit?   ")
              # is there a better way to do the math?
              celsius = (fahrenheit - 32)*.556
              print "That equals %0.1f degrees Celsius" %celsius
         else:
              celsius = input (" What is the temperature in degrees
Celsius?")
              # ditto
              fahrenheit = (celsius *1.8)+32
              print "That equals %0.1f degrees Fahrenheit" %fahrenheit
              # gives user choice of converting another
         decide = raw_input ("Another? (y)es or (n)o")
         if decide == "y":
              print 'OK, no problem'
else:
              print 'See you later!'







More information about the Python-list mailing list