๐ This question is part of the full practice set
Start free โ 5 days
Subjects โบ Computer Science โบ Exception Handling
Exception Handling
๐ How to approach this chapter
In a typical paper this chapter carries about 1.1 marks. Small chapter - 1 mark MCQs and one 2-mark question some years.
- Syntax errors are found before the program runs; exceptions (run-time errors) happen while running and can be handled.
- try: ... except SomeError: ... else: (runs only if no exception) ... finally: (always runs). A bare except catches everything.
- Common exceptions: ZeroDivisionError, ValueError (int("abc")), TypeError ("5"+3), IndexError, KeyError, NameError, FileNotFoundError, EOFError (end of a pickle file).
- raise lets you throw an exception yourself. Typical 2-mark question: what is the purpose of the finally block, or write code that keeps asking for a number until a valid one is entered.
You can try the first few questions here. Start free for 5 days to open everything.
๐ This question is part of the full practice set
Start free โ 5 days
๐ This question is part of the full practice set
Start free โ 5 days
๐ This question is part of the full practice set
Start free โ 5 days
๐ This question is part of the full practice set
Start free โ 5 days
๐ This question is part of the full practice set
Start free โ 5 days
๐ This question is part of the full practice set
Start free โ 5 days