Inheritance

Inheritance allows one class to derive properties and behavior from another class.

This promotes code reuse and logical hierarchy.

class Animal:
  def speak(self):
    print("Animal speaks")

class Dog(Animal):
  def speak(self):
    print("Dog barks")

my_dog = Dog()
my_dog.speak()  # Output: Dog barks
← PrevNext →