Bird
Raised Fist0

Which built-in Python class should a custom exception usually inherit from?

easy🧠 Conceptual Q2 of Q15
Python - Custom Exceptions
Which built-in Python class should a custom exception usually inherit from?
Astr
Blist
Cint
DException
Step-by-Step Solution
Solution:
  1. Step 1: Identify the base class for exceptions

    Python's standard exceptions inherit from the Exception class.
  2. Step 2: Confirm inheritance

    Custom exceptions should inherit from Exception to behave like standard errors.
  3. Final Answer:

    Exception -> Option D
  4. Quick Check:

    Custom exceptions inherit from Exception [OK]
Quick Trick: Always inherit custom exceptions from Exception [OK]
Common Mistakes:
MISTAKES
  • Inheriting from unrelated types like list or int
  • Not inheriting from any class
  • Inheriting from str by mistake

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes