Question: ( a ) Describe briefly what an exception is , and explain the usage of the try, except and finally statements. ( b ) The

(a) Describe briefly what an exception is, and explain the usage of the try, except and finally statements. (b) The following program asks the user for a temperature in degrees Fahrenheit, and prints the temperature in degrees Celsius instead. def f2c(x): return 5*(x-32)/9 s = input("Enter a temperature in F:") f = float(s) print("{}F is {}C".format(f, f2c(f))) This program crashes if the user enters a string that cannot be converted to a float. Rewrite the program using try and except so that it repeatedly asks the user for a string, until a string that can be converted to a float is given, before printing the result.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!