Complete the code to define a class B that inherits from class A.
class A: def greet(self): print("Hello from A") class B([1]): pass
Class B inherits from class A, so we write B(A).
Complete the code to call the greet method from class A inside class B.
class A: def greet(self): print("Hello from A") class B(A): def greet(self): [1].greet(self) print("Hello from B")
self.greet() which causes recursion.super().greet() which is correct but not the answer here.To call the greet method from class A, use A.greet(self).
Fix the error in the multiple inheritance class C that inherits from B and A.
class A: def greet(self): print("Hello from A") class B(A): def greet(self): print("Hello from B") class C([1]): pass
Class C inherits from B and A in that order to demonstrate the diamond problem: C(B, A).
Fill both blanks to complete the method in class C that calls greet using super().
class C(B, A): def greet(self): [1]().greet() print("Hello from C")
self.greet() which causes recursion.Use super() to call the next method in the method resolution order.
Fill both blanks to create a dictionary comprehension that maps class names to their greet method outputs if the class is a subclass of A.
classes = [A, B, C]
result = {({BLANK_2}}.__name__: [2]().greet() for [1] in classes if issubclass([2], A))This dictionary comprehension creates a dictionary where keys are class names and values are the result of calling greet on an instance of that class.