Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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.125Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started