Question 5 of 8beginner🧠 RememberVery Short3 marks

Define the following:

(a)

Exception Handling

Answer

Exception Handling is the process where a programmer anticipates erroneous situations that may arise during execution and addresses them by including appropriate code to handle the exception so that the program does not terminate abnormally.

(b)

Throwing an exception

Answer

Throwing an exception refers to the event when an error occurs during the execution of a program. When such an error happens, an exception is said to have been raised, represented as a Python object.

(c)

Catching an exception

Answer

Catching an exception involves defining handler codes inside an except clause to handle the matching exception raised in the try block.

Explanation

The answer is derived directly from Section 1.3 'Exceptions' and the Summary of the provided text. Part (a) is defined based on the text stating that a programmer 'may anticipate such erroneous situations... and can address them by including appropriate code'. Part (b) is based on the line 'When an error occurs during the execution of a program, an exception is said to have been raised'. Part (c) is based on the summary stating that 'Inside each except clause we define handler codes to handle the matching exception raised in the try block'.