SOARDO
Software Engineer (SDE)pythonintermediate3 interactive MCQs in app

Inheritance, MRO & super()

super() & C3 MRO single base executionComposition vs Inheritance ("has-a" vs "is-a")Liskov behavioral substitutability

Use Inheritance (`is-a`) strictly when subclasses share and honor the parent’s behavioral contract (Liskov Substitution), calling `super().__init__(...)` so Python’s C3 **Method Resolution Order (`Class.__mro__`)** invokes each ancestor cleanly ONCE in diamond hierarchies (`A <- B, C <- D`). Prefer **Composition (`has-a`)** (`Grader` *has a* `ProviderClient`) whenever behavior swaps at runtime or classes don’t share a deep hierarchy!

in diamond `D(B, C)` over `A`, `D.__mro__` is `[D, B, C, A, object]`, so `super().__init__()` guarantees `A.__init__` executes strictly once!
calling `Parent.__init__(self)` directly instead of `super().__init__()` runs base initializers TWICE in diamond multiple inheritance.
Inheritance and Composition — Real Pythonread ↗Exercism Python Track (Interactive)practice ↗

Practice Inheritance, MRO & super() with 3 graded MCQs & written feedback.

Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.

Test yourself free on SOARDO →View full Software Engineer roadmap

More Software Engineer Study Guides