class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width
def area(self):
return self.length * self.width
class Square(Rectangle):
def __init__(self, length):
# Call the __init__ method of the parent class (Rectangle)
# super() refers to the parent class of this class
# Actually using the __init__ method of `Rectangle` here
# which needs 2 parameters, `length` and `width`. Since
# a square is length==width then we use `length` twice.
super().__init__(length, length)
my_square = Square(5)
my_square.area() # 25