CHALLENGE ACTIVITY 10.2.1: Enter the output of multiple exception handlers. 375510.2350218.qx3zqy7 Jump to level 1 1 Typ
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
CHALLENGE ACTIVITY 10.2.1: Enter the output of multiple exception handlers. 375510.2350218.qx3zqy7 Jump to level 1 1 Typ
CHALLENGE ACTIVITY 10.2.1: Enter the output of multiple exception handlers. 375510.2350218.qx3zqy7 Jump to level 1 1 Type the program's output 2 2 心。」。 a numbers = [2, 4, 5, 81 user_input = input() while user_input != 'end': try: # Possible ValueError divisor = int(user_input) if divisor > 20: # Possible Name Error # compute() is not defined result = compute (result) elif divisor < 0: # Possible IndexError result = numbers [divisor] else: # Possible ZeroDivisionError result = 20 // divisor print (result, end='') except (ValueError, ZeroDivisionError): print('r', end='') except NameError, IndexError): print('s', end='') user_input = input () print ('OK') Input -2 5 5 98 0 0 -6 six end # // truncates to an integer Output 2 3 Check Next Feedback?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!