Method Resolution Order (MRO) Basics

Medium Advanced Inheritance & MRO
Solve in Playground →

Problem Statement

Create classes `A`, `B` inheriting from `A`, `C` inheriting from `A`, and `D` inheriting from `B` and `C`. Define a `greet(self)` method in all of them printing ‘I am [ClassName]’. Instantiate `D` and call `greet()`. Observe which method gets executed.

Input Format

None

Output Format

Print the greeting from the resolved class.

Constraints

None

Sample Output

I am D

Explanation

Python resolves method calls using the Method Resolution Order (MRO), starting with the current class and moving left-to-right, depth-first through base classes.

Starter Code

class A:
    def greet(self): print('I am A')

class B(A):
    def greet(self): print('I am B')

class C(A):
    def greet(self): print('I am C')

# Define D inheriting from B and C
class D:
    pass

if __name__ == '__main__':
    # Instantiate D and call greet()
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used