Learn

Perfect! Now we’re ready to start creating objects.

We can access attributes of our objects using dot notation. Here’s how it works:

class Square(object): def __init__(self): self.sides = 4 my_shape = Square() print my_shape.sides
  1. First we create a class named Square with an attribute sides.
  2. Outside the class definition, we create a new instance of Square named my_shape and access that attribute using my_shape.sides.

Instructions

1.

Outside the Animal class definition, create a variable named zebra and set it equal to Animal("Jeffrey").

Then print out zebra‘s name.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?