GCGrowCarrer

Inheritance

Locked

Lesson 17 of 60 · OOP · Medium

Finish these first:Classes and Objects →Or pass the tests below to unlock it now.

1

The big idea

Subclasses reuse and override behaviour. super() calls the parent.

Think of it like this: Think of a Class as a cookie cutter (the blueprint) and each Object as an individual cookie stamped from it — each cookie can have its own frosting (state) while sharing the same shape (methods).
Key words (tap to learn):
2

Read the lesson

Subclasses reuse and override behaviour. super() calls the parent. Python supports multiple inheritance via the MRO (Class.__mro__).

class Animal:
    def speak(self): return "..."
class Dog(Animal):
    def speak(self): return "Woof"

Prefer composition over deep inheritance trees.

3

Quick check

Before writing code: What should `Square(3).area()` return when your implementation of Inheritance is working?

4

Your challenge

4 sample tests, 1 hidden

Create Shape with area() returning 0 and Square(side) overriding area().

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to java.inheritance (85% overlap). Python allows multiple inheritance; Java has single class inheritance + interfaces.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Inheritance.

Mastery0%

Learn this first

Opens up next

This is the last lesson in this branch.