Complete the code to add a custom attribute color to the object car.
class Car: pass car = Car() car.[1] = 'red' print(car.color)
To add a custom attribute to an object, assign it using dot notation with the attribute name. Here, car.color = 'red' adds the color attribute.
Complete the code to add a custom attribute age with value 5 to the object dog.
class Dog: pass dog = Dog() dog.[1] = 5 print(dog.age)
Assigning dog.age = 5 adds the age attribute with value 5 to the dog object.
Fix the error in the code to add a custom attribute height with value 180 to the object person.
class Person: pass person = Person() person[1] = 180 print(person.height)
To add an attribute, use dot notation like person.height = 180. Square brackets or other symbols cause errors.
Fill both blanks to add a custom attribute speed with value 100 to the object bike.
class Bike: pass bike = Bike() bike[1] = [2] print(bike.speed)
Use bike.speed = 100 to add the speed attribute with value 100.
Fill all three blanks to add a custom attribute name with value "Alice" to the object user.
class User: pass user = User() user[1] = [2] print(user.[3])
Assign user.name = "Alice" and print user.name to add and display the attribute.