Complete the code to create an instance attribute named 'color' with value 'red'.
class Car: def __init__(self): self.[1] = 'red' my_car = Car() print(my_car.color)
The instance attribute is named 'color', so we assign it with self.color = 'red'.
Complete the code to assign the instance attribute 'name' from the constructor parameter.
class Person: def __init__(self, name): self.[1] = name p = Person('Alice') print(p.name)
The instance attribute should be named 'name' to store the passed parameter name.
Fix the error by completing the code to correctly access the instance attribute 'height'.
class Tree: def __init__(self, height): self.height = height my_tree = Tree(10) print(my_tree.[1])
The attribute is named 'height' exactly, so use my_tree.height to access it.
Fill both blanks to create an instance attribute 'age' and assign it the value passed as parameter.
class Animal: def __init__(self, [1]): self.[2] = age pet = Animal(5) print(pet.age)
The parameter and the instance attribute should both be named 'age' to correctly assign the value.
Fill all three blanks to create an instance attribute 'title' from the parameter and print it.
class Book: def __init__(self, [1]): self.[2] = [3] novel = Book('1984') print(novel.title)
The parameter, the instance attribute, and the value assigned should all use 'title' to work correctly.