Complete the code to define a class with a constructor in object-oriented design.
class Car: def __init__(self, make, model): self.make = make self.model = [1]
The constructor assigns the parameter model to the instance variable self.model. So, model is the correct value.
Complete the code to implement inheritance where class Dog inherits from class Animal.
class Animal: def speak(self): pass class Dog([1]): def speak(self): return "Woof!"
In inheritance, the child class Dog inherits from the parent class Animal. So, Animal is the correct class to inherit from.
Fix the error in the code to correctly override a method in subclass.
class Vehicle: def start(self): return "Vehicle started" class Bike(Vehicle): def start(self): return [1]
super() causing recursion.To override and extend the parent method, use super().start() to call the parent method, then add the subclass behavior.
Fill both blanks to implement encapsulation by making attributes private and providing getter method.
class Person: def __init__(self, name): self.[1]name = name def get_name(self): return self.[2]name
In Python, prefixing attribute names with double underscores __ makes them private (name mangling). The getter accesses the same private attribute.
Fill all three blanks to implement polymorphism with two classes having the same method name but different behavior.
class Cat: def sound(self): return [1] class Cow: def sound(self): return [2] animals = [Cat(), Cow()] results = [animal.[3]() for animal in animals]
Polymorphism allows different classes to have methods with the same name. Here, both Cat and Cow have sound method. The list comprehension calls sound() on each object.