Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a class Child that inherits from Parent1 and Parent2.
Python
class Child([1]): pass
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces instead of commas between parent classes.
Using square brackets instead of parentheses.
Omitting parentheses entirely.
✗ Incorrect
In Python, multiple inheritance is declared by listing parent classes separated by commas inside the parentheses after the class name.
2fill in blank
mediumComplete the code to create an instance of Child class.
Python
obj = [1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase letters for class names.
Trying to instantiate parent classes instead of the child.
✗ Incorrect
Class names are case-sensitive in Python. The class defined is
Child, so the instance must be created with Child().3fill in blank
hardFix the error in the class definition to correctly inherit from ParentA and ParentB.
Python
class MyClass([1]): pass
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces instead of commas.
Using square brackets or dot notation.
✗ Incorrect
Multiple inheritance requires listing parent classes separated by commas inside parentheses.
4fill in blank
hardFill both blanks to define a class MultiChild that inherits from Base1 and Base2 and create an instance named instance.
Python
class MultiChild([1]): pass instance = [2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one parent class in inheritance.
Trying to instantiate a parent class instead of the child.
✗ Incorrect
The class inherits from both Base1 and Base2 separated by commas. The instance is created from the class MultiChild.
5fill in blank
hardFill all three blanks to define a class FinalChild inheriting from Alpha and Beta, create an instance obj, and call its method().
Python
class FinalChild([1]): def method(self): return "Hello" obj = [2]() print(obj.[3]())
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one parent class.
Calling a method that does not exist.
Using wrong class or method names.
✗ Incorrect
The class inherits from Alpha and Beta. The instance is created from FinalChild. The method called is 'method'.