import javax.swing as swing def input(message): return float(swing.JOptionPane.showInputDialog(message)) # A program for converting Fahrenheit temperatures to Centigrade. # This program contains an unusually large number of COMMENTS like #this: lines that start with # and are ignored by the python interpreter, #but are there for people to read. def FtoC(): # # #All our ptograms begin this way, with the keyword def, the name #of the 'function' we are defining, and a (possibly empty) list #of arguments between parentheses, then a colon. # # # ftemp=input("Enter the temperature in Fahrenheit.") #ftemp=input("Enter the temperature in Fahrenheit.") #Statements following the colon are indented one tab stop. #We could have used JES's special requestNumber function for #this as well (this is what we did in class) #but the input function is standard python, and does the job. # # ctemp=5.0/9*(ftemp-32) # #This statement illustrates several things: Forcing floating-point #division instead of integer division, precedence of operators, #assignment to a variable print "The temperature in centigrade is ",ctemp," degrees."