Why would a programmer extend built-in exceptions in Python?
easy📝 Conceptual Q1 of 15
Python - Custom Exceptions
Why would a programmer extend built-in exceptions in Python?
ATo make the program run faster
BTo avoid using try-except blocks
CTo create specific error types for clearer error handling
DTo automatically fix errors in the code
Step-by-Step Solution
Solution:
Step 1: Understand the purpose of extending exceptions
Extending exceptions allows programmers to create specific error types that describe unique problems in their code.
Step 2: Compare options with this purpose
Only To create specific error types for clearer error handling matches this purpose. Options A, C, and D are incorrect because extending exceptions does not affect speed, remove the need for try-except, or fix errors automatically.
Final Answer:
To create specific error types for clearer error handling -> Option C
Quick Check:
Purpose of extending exceptions = Create specific error types [OK]
Quick Trick:Custom exceptions clarify error causes for better debugging [OK]