Brainlag
  1. Python
  2. Advanced
31/42 lessons

Inheritance: classes built on classes

30 min4 exercisesPremium

Python inheritance for beginners: subclasses, overriding a method, super() and super().__init__, isinstance, and when composition is the better choice.

The skill
Build new classes on top of old ones without copying code, and know when not to.
You make
Game enemies that share a base class, VIP gig tickets and a mage that has an inventory.

Premium lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 30 Objects working together. Free to try: Python Foundations and the playground.

Step 1 of 8
exercise_1.py

You've reached the good stuff.

4 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.

Python 3.13