Complete the code to create a public attribute named name in the Person class.
class Person: def __init__(self, [1]): self.name = name p = Person("Alice") print(p.name)
The __init__ method takes name as a parameter to set the public attribute self.name.
Complete the code to access the public attribute color of the Car object.
class Car: def __init__(self, color): self.color = color my_car = Car("red") print(my_car.[1])
To get the value of the public attribute color, use my_car.color.
Fix the error in the code by completing the blank to correctly set the public attribute age.
class Animal: def __init__(self, age): self.[1] = age cat = Animal(3) print(cat.age)
The attribute name must match the one used when accessing it later, which is age.
Fill both blanks to create a public attribute height and print its value.
class Tree: def __init__(self, [1]): self.[2] = height pine = Tree(15) print(pine.height)
The parameter and attribute names should both be height to correctly set and access the value.
Fill all three blanks to create a public attribute width, set it, and print it.
class Box: def __init__(self, [1]): self.[2] = width b = Box(10) print(b.[3])
All blanks should be width to correctly pass, set, and access the public attribute.