1. Home
  2. Data Science
  3. Python
  4. How do you define a custom exception in Python?

Added 25 Nov 2026

How do you define a custom exception in Python?

  1. Subclass Exception Correct answer
  2. Use the custom keyword
  3. Use def exception
  4. Import CustomError

Correct answer

A. Subclass Exception

5 views

MCQSEXAM

Explanation

Custom exceptions inherit from Exception: class MyError(Exception): pass

Reference

Asked in: Python Interview Exception Handling

https://docs.python.org/3/tutorial/errors.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs