Skip to main content

Chapter 60 Quiz

Before taking the quiz, verify that you can do each of these without looking at the lessons:

  • Implement __repr__ and __str__ and explain when Python calls each
  • Implement __eq__ with isinstance check and NotImplemented
  • Implement __len__, __getitem__, and __contains__ on a collection
  • Implement __iter__ using yield on a collection
  • Implement __hash__ consistent with __eq__ and explain the contract

If any feel uncertain, revisit the specific lesson before continuing.

Test your understanding of special methods by predicting output, identifying missing methods, evaluating protocol consistency, and analyzing design decisions.

Checking access...