Method Resolution Order (MRO) in Python
Which three statements about the Method Resolution Order (MRO) in Python are true? (Choose three.)
Quick Answer
The answer is that in diamond inheritance, the topmost base class is visited last. This is correct because Python’s Method Resolution Order (MRO) follows the C3 linearization algorithm, which ensures a consistent, monotonic search path through the inheritance hierarchy. The algorithm guarantees that a child class is always checked before its parents, and when multiple parent classes share a common ancestor, that ancestor is only visited after all its subclasses have been exhausted. On the Certified Associate Python Programmer PCAP exam, this concept often appears in multiple-choice questions testing your understanding of how Python resolves method calls in complex inheritance, with a common trap being the assumption that Python uses a simple depth-first search. A reliable memory tip is to remember the MRO mantra: “child before parent, and the topmost common ancestor comes last,” which you can verify at any time by inspecting a class’s `__mro__` attribute.
⚠ Common exam trap
Python Institute often tests the misconception that the MRO only applies to methods, when in fact it governs all attribute lookups, including data attributes and descriptors.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The MRO can be viewed using the __mro__ attribute.
Every Python class has an `__mro__` attribute that returns a tuple of classes in the order they are searched for methods and attributes. This attribute is automatically generated by the C3 linearization algorithm and provides a clear, inspectable view of the resolution order.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The MRO can be viewed using the __mro__ attribute.
Why this is correct
Each class has a __mro__ attribute showing the order.
- ✓
MRO is determined by the C3 linearization algorithm.
Why this is correct
Python uses C3 linearization to compute MRO.
- ✗
The MRO is only used for methods, not attributes.
Why it's wrong here
MRO affects attribute lookup as well, since attributes are looked up in the same order.
- ✓
In diamond inheritance, the topmost base class is visited last.
Why this is correct
C3 linearization ensures the common ancestor is visited after all derived classes.
- ✗
The MRO can be changed by modifying the class hierarchy at runtime.
Why it's wrong here
MRO is fixed when the class is defined; altering parent classes later does not change MRO.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCAP question from scratch — 169 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
2 more ways this is tested on PCAP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which THREE statements about the Python method resolution order (MRO) are true? (Select exactly 3.)
hard- A.The MRO is determined at runtime when a method is called.
- ✓ B.The MRO of a class can be viewed using the __mro__ attribute.
- ✓ C.C3 linearization is the algorithm used for MRO in Python 3.
- D.Python uses a depth-first left-to-right algorithm for MRO.
- ✓ E.super() uses the MRO to determine which method to call.
Why B: The `__mro__` attribute on a class returns a tuple of classes in the exact order that Python uses to resolve methods and attributes. This attribute is computed at class definition time using the C3 linearization algorithm, and it provides a direct, read-only view of the resolution order for that class.
Variation 2. Refer to the exhibit. What is the output? (Note: actual MRO may vary; choose the one that matches Python 3 C3 linearization.)
hard- A.(<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>)
- ✓ B.(<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>, <class 'object'>)
- C.(<class '__main__.D'>, <class '__main__.C'>, <class '__main__.B'>, <class '__main__.A'>, <class 'object'>)
- D.(<class '__main__.D'>, <class '__main__.A'>, <class '__main__.B'>, <class '__main__.C'>, <class 'object'>)
Why B: Python 3 uses C3 linearization to compute the Method Resolution Order (MRO). For class D inheriting from B and C, which both inherit from A, the MRO is D, B, C, A, object. This satisfies the monotonicity and local precedence order: B comes before C (as per D's bases), and A is last among the user-defined classes, with object always appended.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.