Complete the code to define the constructor method for a class.
class Car: def [1](self, make, model): self.make = make self.model = model
The constructor method in Python classes is named __init__. It runs when an object is created.
Complete the code to create an object of the class Car.
my_car = Car([1], 'Model S')
When creating an object, string arguments must be in quotes. Here, 'Tesla' is the make.
Fix the error in the method to correctly initialize the attribute.
class Person: def __init__(self, name): self.[1] = name p = Person('Alice') print(p.name)
The attribute name must exactly match the one used when accessing it. Here, self.name matches p.name.
Fill both blanks to create a class with an attribute and a method that returns it.
class Book: def __init__(self, title): self.[1] = title def get_[2](self): return self.title
The attribute is named title, so the method should be get_title to match.
Fill all three blanks to initialize an object with two attributes and a method that returns a formatted string.
class Student: def __init__(self, name, age): self.[1] = name self.[2] = age def info(self): return f"Name: {self.[3], Age: {self.age}"
The attributes name and age must be initialized and used consistently in the method.