0
0
Pythonprogramming~10 mins

Accessing and modifying attributes in Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to access the attribute 'color' of the car object.

Python
print(car.[1])
Drag options to blanks, or click blank then click option'
Ayear
Bspeed
Ccolor
Dmodel
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses like a method call, e.g., car.color()
Trying to access attribute with brackets, e.g., car['color']
2fill in blank
medium

Complete the code to change the 'speed' attribute of the car object to 100.

Python
car.[1] = 100
Drag options to blanks, or click blank then click option'
Aspeed
Bcolor
Cmodel
Dyear
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses like a method call, e.g., car.speed() = 100
Trying to assign to a non-existing attribute
3fill in blank
hard

Fix the error in the code to correctly access the 'model' attribute of the car object.

Python
print(car[1]model)
Drag options to blanks, or click blank then click option'
A["model"]
Bmodel
C->model
D.model
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets like a dictionary: car["model"]
Using arrow notation which is not valid in Python
4fill in blank
hard

Fill both blanks to create a new attribute 'owner' with value 'Alice' for the car object.

Python
car.[1] = [2]
Drag options to blanks, or click blank then click option'
Aowner
B'Alice'
C'Bob'
Dspeed
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string value
Using an existing attribute name instead of a new one
5fill in blank
hard

Fill all three blanks to print the updated 'year' attribute after changing it to 2025.

Python
car.[1] = [2]
print(car.[3])
Drag options to blanks, or click blank then click option'
Ayear
B2025
Dspeed
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number 2025
Printing a different attribute than the one changed