Inheritance
What is Inheritance?
Basic Example
class Vehicle:
def move(self):
print("Vehicle is moving")
class Car(Vehicle): # Car inherits from Vehicle
def honk(self):
print("Car honks: Beep beep!")
my_car = Car()
my_car.move() # Output: Vehicle is moving (inherited)
my_car.honk() # Output: Car honks: Beep beep!Real World Use Cases
Key Points
Last updated