Attributes of a Turtle

Recall that a class is a template for making a type of object. A class tells us what an object can do (functions), as well as what things it keeps track of (attributes). The Turtle class is no different! Since turtley is a Turtle Object, this section will go over some of the attributes and functions that a turtle has.

There are many attributes that we can change about our turtle, but today we’re going to focus on four main ones:

Speed – A number representing how quickly the turtle moves, on a scale of 1-10. A speed of 0 means it will instantly move from point a to point B

Color – A string representing the color of the line that the turtle draws, e.g. “Green”, “LightYellow”, “HotPink”

Size – A number representing how many pixels thick the turtle will draw

Shape – The shape of the turtle itself. By default it looks like an arrow unless we change it.

To set these functions, you will want to use the speed(), pencolor(), pensize(), and shape() functions to set them. Like shown on the right. Before running this, make sure you also have the line “done()” at the bottom of your code. This just tells your turtle that there are no more things to do past this point. (The program will freeze without it)