Stage 2 · 35 min · Pro
Object-oriented programming: classes
Create a class, the __init__ constructor, attributes, methods, self, __str__ and creating several objects.
Objectives
- Define a class with __init__
- Understand self
- Write methods that change an object's state
- Use __str__ to print an object nicely
This lesson is for Pro members
As a program grows, grouping related data and behaviour into one "template" keeps code easy to understand and extend. Most Python libraries (Django, pandas...) are built on classes.
See Pro plans Open in the app