# convert_error_check.py # # Improved version of convert.py, with error checking. def celsius_to_fahrenheit(temperature): """Returns fahrenheit given celsius. Assumes input is numeric.""" return (9.0/5.0)*celsius + 32 def main(): """Ask user for Celsius temperature, then print Fahreneit conversion.""" celsius = input("What is the Celsius temperature? ") try: celsius=float(celsius) print "The temperature is ", celsius_to_fahrenheit(celcius), print " degrees Fahrenheit." except: print "Oops - what you typed isn't a number." return main()