🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Context Managers: all 10 questions

Quiz: Context Managers · Question 5 of 10

What happens if exit returns True after an exception in the block?

What happens if __exit__ returns True after an exception in the block?

  1. A.The exception is raised twice
  2. B.The program stops
  3. C.The exception is suppressed and the program continues after the with block
  4. D.exit is called again
Answer & explanation

Correct answer: The exception is suppressed and the program continues after the with block

A true return value tells Python the exception has been handled.

Can you get the rest right without peeking?

Take the timed Quiz: Context Managers quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →