Complete the code to define a child class that inherits from the parent class.
class Parent: def greet(self): return "Hello from Parent" class Child([1]): pass
The child class must inherit from the parent class by naming it in parentheses.
Complete the code to call the parent class method from the child class.
class Parent: def greet(self): return "Hello from Parent" class Child(Parent): def greet(self): return "Child says: " + [1].greet()
self which causes recursion.Use super() to call the parent class method inside the child class.
Fix the error in the child class constructor to properly call the parent constructor.
class Parent: def __init__(self, name): self.name = name class Child(Parent): def __init__(self, name, age): [1].__init__(self, name) self.age = age
self.__init__ which causes infinite recursion.super() without parentheses or incorrectly.Use the parent class name to call its constructor with Parent.__init__(self, name).
Fill in the blank to create a child class that overrides a method and calls the parent method inside it.
class Parent: def info(self): return "Parent info" class Child(Parent): def info(self): return [1]().info() + " and Child info"
self which causes recursion.Use super() to call the parent class method inside the overridden method.
Fill all three blanks to create a dictionary comprehension that maps child class names to their ages if age is greater than 10.
children = [Child("Anna", 12), Child("Ben", 9), Child("Cara", 15)] ages = { [1]: [2] for child in children if child.age [3] 10 }
The dictionary comprehension uses child.name as key, child.age as value, and filters ages greater than 10.