Skip to main content

Section 20.2 Using Repetition with Turtles

While learning how to draw with the turtle, we have found many reasons to repeat ourselves in ways that a loop can make easier. A simple example is a square procedure - it needs to do both forward and right 4 times. So why not have a for loop repeat those for us:

Checkpoint 20.2.1.

The following program should define a procedure triangle that uses a loop to help draw a triangle. The main part of the program calls that function twice to draw two different triangles.
Arrange and indent the blocks correctly. You will not need them all.

Checkpoint 20.2.2.

The following program uses a turtle to draw a 175x150 rectangle as shown below, but the lines are mixed up. We want to define a rectangle procedure that twice repeats the process to draw half of a rectangle: draw a line for the width, then turn, draw a line for the height, and turn again.
Arrange the blocks into the correct solution and indent them properly. You will not use all of the blocks.
You have attempted of activities on this page.