Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Choose two.)
Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Choose two.)
The given options involve multiple inheritance structures. For a class definition with multiple inheritance to be correct in Python, the parent classes must be inherited in an order that preserves the method resolution order (MRO). The following class declarations are proper: class Class_4(D,A): pass and class Class_1(C,D): pass. In these correct declarations, the MRO can be successfully determined without any inconsistencies. The other options, class Class_3(A,C): pass and class Class_2(B,D): pass, would raise a TypeError because they result in conflicting MROs where a parent class is listed before its subclass, leading to ambiguity.
CaptinPirate answer is answer A and answer D, this will save you checking his/her/they link
A can't be declared from C as A is superclass to C, same goes to B and D. Answer is correct
Ok guys.Here is your answer.I only typed it in VSSCODE and here it is: https://drive.google.com/file/d/122fvfA91ZyKcsq7qlaBQXYcGH0x7e9Ja/view?usp=sharing
How class Class_1(C,D): pass is correct here? D is not sub class of C
only corrects are: A. class Class_4(D,A): pass D. class Class_1(C,D): pass
TypeError: Cannot create a consistent method resolution order (MRO) for bases A, C TypeError: Cannot create a consistent method resolution order (MRO) for bases B, D
class A: pass class B(A): pass class C(A): pass class D(B): pass class Class_4(D,A): pass #class Class_3(A,C): pass#TypeError: Cannot create a consistent method resolution order (MRO) for bases A, C #class Class_2(B,D): pass#TypeError: Cannot create a consistent method resolution order (MRO) for bases A, C class Class_1(C,D): pass Ans is A,D
Why is the corract answer not Class(D,C): pass ?? D -> B -> A C -> A I do not understand why the correct answer is Class(C,D): pass Can someone please explain? Is that because in the inheritance class B cannot be invoked before class C is invoked which is why it's Class(C,D): pass C -> A D -> B -> A (class B invoked later on as it is initialized earlier than class C)
Anyone can please explain this questions?
On multiple inheretance, the Parent cannot be declared before the child: https://www.datacamp.com/community/tutorials/super-multiple-inheritance-diamond-problem
shouldn't this be BC?
Can't be B, class A shouldn't be before class C, because class C is a subclass of class A. The order left and right is important in python.