Exceptions & Files · Question 19 · Hard
Which of these exceptions is NOT caught by a handler written as except Exception:?
- ZeroDivisionError
- KeyError
- KeyboardInterrupt
- 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
- A function returns from inside try, and its finally block has a print. In what…
- All three parts of this try statement contain a return. What does risky() give…
- parse() catches one exception and raises a different one from its handler…
- Two lines are written to an in-memory text file, which is read once before and…
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