Lesson 28 of 34 · Classes & OOP
Quiz: Python Classes and OOP
Object-oriented programming lets you design your own types. In this chapter you created classes with __init__ and self, added methods and class attributes, reused code through inheritance and super(), made objects print and compare naturally with dunder methods, and let dataclasses write the boilerplate for you.
Six questions to check your understanding — then on to the chapter boss.
What this quiz covers
The questions check what you learned in the Classes & OOP chapter of Learn Python. Not sure about a topic? Review its lesson first:
- Python Classes and Objects: __init__, Methods and Attributes
Learn object-oriented Python: define classes, initialise objects with __init__ and self, write methods, and use instance vs class attributes.
- Python Inheritance and super()
Reuse code with Python inheritance: create subclasses, override methods, extend parent classes with super() and check types with isinstance().
- Python Dunder Methods: __str__, __repr__ and __eq__
Make Python classes feel built-in with dunder (magic) methods: __str__ and __repr__ for printing, __eq__ for equality and __add__ for operators.
- Python Dataclasses
Cut boilerplate with Python dataclasses: auto-generated __init__, __repr__ and __eq__, default values, default_factory, frozen and ordered classes.
Keep learning
Need a quick reminder? The Python cheat sheet has every topic of Learn Python on one page.
Lesson last updated on .