Method Overriding & super()
Method overriding lets child classes provide different implementations of parent methods. super() calls the parent's version.
15 min•By Priygop Team•Updated 2026
Method Overriding
Method Overriding
class Shape:
def __init__(self, color="black"):
self.color = color
def area(self):
return 0
def describe(self):
return f"A {self.color} shape with area {self.area():.2f}"
class Circle(Shape):
def __init__(self, radius, color="red"):
super().__init__(color)
self.radius = radius
def area(self): # Override parent method
return 3.14159 * self.radius ** 2
class Rectangle(Shape):
def __init__(self, width, height, color="blue"):
super().__init__(color)
self.width = width
self.height = height
def area(self): # Override
return self.width * self.height
# Polymorphic behavior
shapes = [Circle(5), Rectangle(4, 6), Circle(3, "green")]
for shape in shapes:
print(shape.describe())Tip
Tip
Override methods to specialize behavior. super().method() calls the parent version if you need to extend rather than replace.
Diagram
Loading diagram…
Inheritance lets child classes reuse parent code
Common Mistake
Warning
Forgetting to call super() when overriding __init__ means parent setup is skipped. The child won't have parent attributes.
Practice Task
Note
(1) Create Shape → Circle/Rectangle with area() override. (2) Create a list of mixed shapes and call describe() on each.