← Python

OOP – Inheritance (basic)

A child class inherits methods and attributes from a parent class by naming it in parentheses

What it does: Dog gets all of Animal's methods and attributes automatically. super().__init__() sets up the parent's attributes in the child. Inheritance lets a child class reuse all the code already written in the parent. The class in parentheses is the parent — Dog inherits from Animal. super() gives you a reference to the parent class so you can call its methods. Child classes inherit all parent methods without needing to copy them. Defining speak() in Dog replaces the inherited version — called method overriding. isinstance() returns True for the object's class AND all its parent classes.

Common mistakes: Should call super().__init__(name) to use the parent's initialization. Parent's __init__ expects name must pass it: super().__init__(name).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What is inheritance?
A child class gets methods from a parent classCopying a file
Matches
❌ class Dog(Animal)
Error: Missing colon at end of class definition
Applying
Meanings
Term
Inheritance
Meaning
A child class receives methods and attributes from a parent class.
Practice
class Animal:
Testing
Gaps
class Dog():
Check Answer
Spots
2 def __init__(self, name, breed):
3 self.name = name

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Giant Isopod' badge — Patient Builder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What is inheritance?
A. A child class gets methods from a parent class ✓
B. Copying a file
Inheritance lets a child class reuse all the code already written in the parent
2. class Dog(Animal): what is Animal?
A. The child class
B. The parent (base) class ✓
The class in parentheses is the parent — Dog inherits from Animal
3. What does super() do?
A. Accesses the parent class ✓
B. Creates a new class
super() gives you a reference to the parent class so you can call its methods
4. If Animal has speak(), does Dog get it?
A. No must redefine
B. Yes automatically through inheritance ✓
Child classes inherit all parent methods without needing to copy them
5. Can Dog override Animal's speak()?
A. Yes define speak() in Dog ✓
B. No parent methods are locked
Defining speak() in Dog replaces the inherited version — called method overriding

Match the Pairs

class Dog(Animal) Error: Missing colon at end of class definition
super(Animal).__init__() Error: super() takes no arguments in Python 3
class Dog(Animal): Valid: Dog inherits from Animal
super().__init__() Ok: Calls the parent class constructor
issubclass(bool, int) Output: True
isinstance(True, int) Output: True

Key Term

Inheritance
A child class receives methods and attributes from a parent class.~~Parent class

Fill in the Blanks

1. class Dog(Animal): pass
2. class Dog(Animal): def __init__(self, name, breed): super().__init__(name)
3. class Dog(Animal): def speak(self): return self.name + ' says Woof!' # this overrides the parent
4. dog = Dog('Rex') print(isinstance(dog, Animal))
5. class Circle(Shape): def __init__(self, color, radius): super().__init__(color)

Spot the Error

Question 1
A class Dog(Animal):
B def __init__(self, name, breed):
C self.name = name
D self.breed = breed
Line C — Should call super().__init__(name) to use the parent's initialization
Question 2
A class Dog(Animal):
B def __init__(self, name, breed):
C super().__init__()
D self.breed = breed
Line C — Parent's __init__ expects name must pass it: super().__init__(name)
Question 3
A class Dog extends Animal:
B def __init__(self, name):
C super().__init__(name)
D def bark(self):
E return 'Woof!'
Line A — Python uses parentheses for inheritance, not 'extends' (that's Java)
Question 4
A class Dog(Animal):
B def __init__(self, name):
C super.__init__(name)
Line C — super needs parentheses: super().__init__, not super.__init__
Question 5
A class Animal:
B def speak(self):
C return 'Sound'
D
E class Dog(Animal):
F def speak():
G return 'Woof'
Line F — Override method needs self parameter too
For Teachers

Create a free class, add this module to a journey, and track who's stuck.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?