Sharpen your understanding of Object-Oriented Programming with these fill-in-the-blank exercises on Python inheritance. Perfect for students, beginners, and interview prep to reinforce key OOP concepts in Python.
class Person:
def __init__(self, name):
self.name = name
def introduce(self):
print(f"Hi, I'm {self.name}")
class Student(Person):
def study(self):
print(f"{self.name} is studying.")
inherits
class Vehicle:
def __init__(self, brand):
self.brand = brand
def drive(self):
print("The vehicle is moving.")
class Car(Vehicle):
def __init__(self, brand, model):
super().__init__(brand)
self.model = model
def drive(self):
print(f"The {self.brand} {self.model} is driving.")
Vehicle