ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
try:
    try:
        1 / 0
    except ZeroDivisionError:
        raise ValueError("v")
except ValueError as e:
    print(type(e.__context__).__name__, e.__cause__, e.__suppress_context__)
  1. A. ZeroDivisionError ZeroDivisionError True
  2. B. None None False
  3. C. ZeroDivisionError None False
  4. D. ZeroDivisionError None True

Correct answer: C. ZeroDivisionError None False

Raising inside an except block implicitly chains: __context__ is the ZeroDivisionError. Without `raise ... from`, __cause__ stays None and __suppress_context__ is False.

More Python Programming questions

Exams that ask this topic