Skip to main content

Chapter 51 Quiz

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

  • Name the three dict problems: List the three specific problems with dict[str, str] for structured data
  • Explain what @ does: Write the longhand equivalent of a @decorator and explain why both forms are identical
  • Define a dataclass: Write a class with @dataclass, three typed fields, and create an instance
  • Configure defaults: Add default values, use field(default_factory=list), and explain why = [] is forbidden
  • Apply frozen: Use @dataclass(frozen=True) and predict what happens when you try to modify a field
  • Write a dataclass test: Create two instances with the same fields and assert they are equal

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

Test your understanding of Python data models by solving real-world scenarios involving dict fragility, decorators, dataclass definitions, field configuration, and testing.

Checking access...