Accessing MRO via __mro__ and mro()

Medium Advanced Inheritance & MRO
Solve in Playground →

Problem Statement

Using the same `A`, `B`, `C`, `D` diamond structure from the previous task, programmatically print the MRO of class `D`. Extract the `__name__` of each class in `D.__mro__` and print them joined by ‘ -> ‘.

Input Format

None

Output Format

Print the MRO chain.

Constraints

None

Sample Output

D -> B -> C -> A -> object

Explanation

The `__mro__` attribute stores a tuple of classes showing the exact linear search path Python uses to look up methods.

Starter Code

class A: pass
class B(A): pass
class C(A): pass
class D(B, C): pass

if __name__ == '__main__':
    # Iterate through D.__mro__ and print the formatted string
    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