Question: Using python, write code for problem. Please also put screenshot of your code. The following program will perform properly if the user enters 0 in

Using python, write code for problem. Please also put screenshot of your code.

Using python, write code for problem. Please also put screenshot of your

The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1 print ("The reciprocal of {0} is (1:, 3f)". format (n, reciprocal)) break else: print ("You entered zero. ") Enter a nonzero integer: 0 You entered zero. Enter a nonzero integer: eight You did not enter a nonzero integer. Enter a nonzero integer: 8 The reciprocal of 8 is 0.125

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 Databases Questions!