Stage 2 · 35 minutes · Pro
Object-oriented programming: class
Create classes, the __init__ constructor, attributes, methods, self, __str__, and many objects.
Objectives
- Define a class with __init__
- Understand self
- Write methods that change an object state
- Use __str__ to print objects nicely
Lesson for Pro members
As programs grow, grouping related data and behaviour into one 'mould' makes code easier to understand and extend. Most Python libraries (Django, pandas...) are built on classes.
View Pro plans Open in the app