Skip to main content

Section 17.1 History of Turtles

The idea of a virtual turtle, dates back to the 1960โ€™s. Seymour Papert and his group at MIT created the programming language LOGO which could control a robot turtle with a physical pen in it. Kids would steer the robot around, and it would draw as it moved. Seymour said that the Turtle was, โ€œan object to think withโ€. Many modern programming languages support Turtles, including Python.
Figure 17.1.1. Figure 3: Children playing with a Logo turtle robot that could draw with a pen

Subsection 17.1.1 A First Turtle Program

Today, we can play with virtual turtles in a fully-graphical and non-robotic way. Below is a Python program that first creates a Screen object (object of the Screen class) for the turtle to draw on and then creates a Turtle object (object of the Turtle class). The program asks the turtle object to perform some of its behaviors (methods) like moving forward a set amount and turning. The turtle draws as it moves.

Activity 17.1.2.

Click the Run button to see what this code does. The drawing will happen below the code.

Activity 17.1.3.

Which way does a turtle (object of the Turtle class) face when it is first created?
  • North
  • Some systems start with the turtle facing North, but not this one.
  • South
  • Which way does the turtle first move in the example above? North is at the top of the page.
  • East
  • Turtles start off facing east which is toward the right side of the page.
  • West
  • Which way does the turtle first move in the example above? North is at the top of the page.

Note 17.1.4.

Notice that we tell alex the turtle what to do in the code above using dot notation: alex.forward(150), alex.left(90), and alex.forward(75). That is how you communicate with an object. You use the name of the turtle object followed by a . and then the name of the method that you want to execute.
Just by going forward and turning we can have a turtle object draw many things.

Subsection 17.1.2 What does a left turn of 90 mean?

When we ask a turtle to turn left, it will turn left based on the direction it is currently heading. A turtle object keeps track of its heading (direction it is facing). Use the figure below to help you understand how much the turtle will turn if asked to turn left 90 degrees and it is currently heading east (0 degrees).
Figure 17.1.5. Figure 1: The amount of turn for specified degrees for left and right turns
You have attempted of activities on this page.