5.3. Instances: A Herd of Turtles

Just like we can have many different integers in a program, we can have many turtles. Each of them is an independent object and we call each one an instance of the Turtle type (class). Each instance has its own attributes and methods — so alex might draw with a thin pink pen and be at some position, while tess might be going in her own direction with a fat black pen. So here is what happens when alex completes a square and tess completes her triangle:

Here are some How to think like a computer scientist observations:

Check your understanding

Mixed up programs

You have attempted of activities on this page