QuestionQ21

VerifiedExceptions

What is the anticipated behavior of the following code?

Question Image

Explanation

Dividing by zero raises ZeroDivisionError, a subclass of ArithmeticError. The inner handler increments m and re-raises the exception; the outer ArithmeticError handler catches it and increments m once more. The final value printed is 2.

Community Discussion

No comments yet. Be the first to start the discussion!