Children of the blueprint
Inheritance as Genetics
The analogy
A Townhouse is a House — it inherits the walls, the roof and the front door without redrawing them, then adds a shared side wall of its own. Like a child inheriting eye colour: you get the family traits for free, plus whatever is uniquely yours.
Visualizer
Traits flowing down the family
step 1 / 7One parent class, two children, one grandchild.House declares: openDoor(), windows, address
class House:
def open_door(self):
return "creak"
class Townhouse(House): # inherits everything
pass
class Cottage(House):
pass
Townhouse().open_door() # "creak" — for freeCheck yourself
Townhouse extends House. Does Townhouse have House's openDoor()?