Inheritance lets one class start from another: write the general Animal once, and every Dog gets it all for free.
1 IS-A Relationships
class Dog(Animal) reads like a sentence: a dog IS an animal — it starts with everything Animal has.
2 Reuse the Setup
The parent __init__ still works for children; call it with super() and add only what is new.
3 Override Wisely
A child can redefine a method — its version wins without touching the parent.
4 One Family Tree
isinstance checks follow the family tree — a Dog counts as an Animal too.
Classes that stand on classes
IS-A Relationships1class Dog(Animal) reads like a sentence: a dog IS an animal — it starts with everything Animal has. Reuse the Setup2The parent __init__ still works for children; call it with super() and add only what is new. Override Wisely3A child can redefine a method — its version wins without touching the parent. One Family Tree4isinstance checks follow the family tree — a Dog counts as an Animal too. 4 building blocks make up Classes that stand on classes
Dog defines no __init__ — so the inherited one runs. Dog DOES define speak — so its own runs.
mainclass Animal — the base blueprint: every animal gets a name in __init__.
Memory
no variables yet — press play
Console
output appears as the program runs…
Python looks on the actual class first, then walks up the family tree — first definition found wins.
process decision input / output start / end Click a term, then click its description to lock the pair.
5 conceptsTap a card to expand ?class Dog(Animal):drops into place
?super().__init__(name)drops into place
?overridedrops into place
?isinstance(rex, Dog)drops into place
?isinstance(rex, Animal)drops into place
super() in action: the child adds ears but still uses the parent setup.
Your predicted output — one line per console line
Hint: Cat.__init__ first delegates to super() so the name is stored, then adds ears. A Cat is still an Animal.
01class Dog(Animal): makes Dog a subclass; Animal is the base class.
02Anything the parent defines, the child inherits — including __init__.
03super().__init__(name) runs the parent setup before adding child extras.
04A child may override a method; Python uses the child version for its objects.
05isinstance(obj, Base) is True for the whole family tree, not just the exact class.