Learn
Calling class member variables works the same whether those values are created within the class (like our car’s condition
) or values are passed into the new object at initialization. We use dot notation to access the member variables of classes since those variables belong to the object.
For instance, if we had created a member variable named new_variable
, a new instance of the class named new_object
could access this variable by saying:
new_object.new_variable
Instructions
1.
Now that you’ve created my_car
print its member variables:
- First
print
the model ofmy_car
. Click “Stuck? Get a hint!” for an example. - Then
print
out the color ofmy_car
. - Then
print
out the mpg ofmy_car
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.