Courses/Object-Oriented Python

🧱 Object-Oriented Python

Inheritance

Build new classes by extending existing ones.

A subclass inherits everything from its parent and can override or add methods. Call the parent's method with super().

class Animal:
    def __init__(self, name):
        self.name = name
    def speak(self):
        return "..."

class Cat(Animal):
    def speak(self):
        return f"{self.name}: meow"
main.py
Output
Press Run to execute.
Expected output
16

Sign in to track your progress across lessons.