Lesson 33 of 34
Inheritance: Building on a Class
10 min 35 XP
A class can inherit everything from another class, then add or change (override) things. No need to rewrite code.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.super() calls the parent class's method. It's most often used in __init__.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The four pillars of OOP: Encapsulation, Inheritance, Polymorphism and Abstraction. Interviewers ask about them often!