Exceptions & Files · Question 19 · Hard

Which of these exceptions is NOT caught by a handler written as except Exception:?

  1. ZeroDivisionError
  2. KeyError
  3. KeyboardInterrupt
  4. FileNotFoundError
Answer and explanation

Answer: C. KeyboardInterrupt

Explanation: KeyboardInterrupt derives directly from BaseException, not from Exception, so that Ctrl+C is not swallowed by ordinary handlers. The other three are all subclasses of Exception.

Previous: parse() catches one exception and raises a different one from its handler… · Next: Two lines are written to an in-memory text file, which is read once before and…

Practise exceptions & files

Try a fresh set of exceptions & files questions with an explanation after every answer, free and without signing up: Exceptions & Files practice. Or sit a full placement mock test.

More exceptions & files questions

More python practice

Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge