Complete the code to define a class that inherits from another class.
class Animal: def sound(self): return "Some sound" class Dog([1]): pass
The class Dog inherits from Animal to reuse its methods.
Complete the code to call the inherited method from the child class instance.
class Animal: def sound(self): return "Some sound" class Cat(Animal): pass pet = Cat() print(pet.[1]())
The Cat class inherits the sound method from Animal, so calling pet.sound() works.
Fix the error in the code by completing the inheritance syntax correctly.
class Vehicle: def move(self): return "Moving" class Car[1]Vehicle): pass
The class Car must inherit from Vehicle using parentheses: class Car(Vehicle):.
Fill both blanks to create a child class that overrides a method from the parent class.
class Bird: def fly(self): return "Flying" class Penguin([1]): def fly(self): return [2]
Penguin inherits from Bird but overrides the fly method to return "Cannot fly".
Fill all three blanks to create a class hierarchy and call a method from the grandparent class.
class LivingThing: def breathe(self): return "Breathing" class Animal([1]): pass class Dog([2]): def breathe(self): return super().[3]()
Animal inherits from LivingThing. Dog inherits from Animal and calls the breathe method from the grandparent using super().