LearnFrenzy
Sign in Take a free test

Inheritance and Polymorphism · Inheritance and Polymorphism MCQ · Question 13

Returning NotImplemented Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 13 Back to Exercise

What should __add__ return when it does not support the other operand's type?

  • A None
  • B False
  • C raise NotImplementedError
  • D NotImplemented Correct
Correct Answer: Option D

NotImplemented lets Python try the reflected method and, if that fails too, raise a proper TypeError.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links