OOP FundamentalsBeginner
1Question 1 of 1
pythonWhat are the core OOP principles in Python (Inheritance, Polymorphism, super())?
Explanation & Concept
Python supports object-oriented programming with multiple inheritance, method overriding, and duck typing. `super()` delegates method calls to the next class in the Method Resolution Order (MRO).
Code Example
python
class Vehicle:
def __init__(self, brand: str):
self.brand = brand
def describe(self) -> str:
return f"Vehicle brand: {self.brand}"
class ElectricCar(Vehicle):
def __init__(self, brand: str, battery_kwh: int):
super().__init__(brand) # Calls parent constructor
self.battery_kwh = battery_kwh
def describe(self) -> str:
return f"{super().describe()}, Battery: {self.battery_kwh}kWh"
car = ElectricCar("Tesla", 82)
print(car.describe()) # Vehicle brand: Tesla, Battery: 82kWhHow It Works & Key Takeaways
`super()` ensures cooperative multi-inheritance calls and guarantees the entire inheritance hierarchy is properly initialized.
Mock Test · 1 Questions · Optional
Ready for GIL & Multithreading?
Take a quick test to evaluate yourself, or move straight to the next module.
Beginner1 questions