The following code uses exception handling to xe "except clause"catch and xe "handle (or resolve) an exception"handle any ValueErrors and ZeroDivisionErrors that arise. 1 while True:
2 try:
3 number1 = int(input('Enter numerator: ') )
4 number2 = int(input('Enter denominator: ') )
5 result = number1 / number2
6 except ValueError:
7 print('You must enter two integers\n')
8 except ZeroDivisionError:
9 print('Attempted to divide by zero\n')
10 else:
11 print(f'{number1:.3f} / {number2:.3f} = {result:.3f}')
12 break
Where in the code could either or both of these errors arise?
A) line 3
B) line 5
C) lines 3 and 4
D) lines 3, 4 and 5
Correct Answer:
Verified
Q20: Which of the following statements a), b)
Q21: b. When there are except handlers, program
Q22: The int function raises a _ if
Q23: Which of the following statements a), b)
Q24: Which of the following statements is false?
A)
Q25: Which of the following statements a), b)
Q26: Which of the following statements a), b)
Q28: Which of the following statements is false?
A)
Q29: Which of the following statements a), b)
Q30: Which of the following statements is false?
A)
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents