QuestionQ41

VerifiedExceptions

Which of these code snippets runs without causing any unhandled exceptions?

Choose two
Explanation

A try statement’s else clause runs when the try suite completes without an exception, so A prints the two valid division results. In B, assigning and subsequently incrementing x are valid operations. C attempts to use the undefined name y again inside its exception handler, and D raises ZeroDivisionError, not NameError.

Community Discussion

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