Section 20.6 More Turtle Repetition Practice
This section provides more practice using repetition and turtles.
Mixed up program
Checkpoint 20.6.1.
The following program uses the stamp method to create an X of turtle shapes as shown below, but the lines are mixed up. The program should do all necessary set-up, create the turtle, set the shape to “turtle”, and pick up the pen. Stamp the blue turtles before you stamp the green ones.
Arrange and indent the blocks correctly. You will not need them all.
from turtle import *
---
nick = Turtle()
nick.shape("turtle")
---
nick.penup()
---
nick.penUp() #distractor
---
nick.goto(-150,-150)
nick.left(45)
---
nick.goto(-150,-150)
nick.left(90) #distractor
---
nick.color("blue")
for num in range(15):
nick.stamp()
nick.forward(30)
---
nick.goto(150,-150)
nick.left(90)
---
nick.goto(150,-150)
nick.left(45) #distractor
---
nick.color("green")
for num in range(14):
---
nick.stamp()
nick.forward(30)
Checkpoint 20.6.2.
The following program uses the stamp method to create two squares of turtle shapes as shown below, but the lines are mixed up. The program should do all necessary set-up, create the turtle, set the shape to “turtle”, and pick up the pen. Draw the blue square before you draw the green one.
Arrange and indent the blocks correctly. You will not need them all.
from turtle import *
nick = Turtle()
nick.shape("turtle")
nick.penup()
---
nick.goto(-150,-150)
nick.left(90)
---
nick.goto(-150,-150)
nick.right(90) #distractor
---
nick.color("blue")
for count in range(4):
for num in range(5):
nick.stamp()
nick.forward(30)
nick.right(90)
---
nick.goto(-120,-120)
nick.color("green")
for count in range(4):
---
for num in range(3):
---
for num in range(2): #distractor
---
nick.stamp()
nick.forward(30)
---
nick.right(90)
---
nick.left(90) #distractor
Checkpoint 20.6.3.
In the program below, we want to draw a series of polygons, from 10 sides down to 3 sides, each with a side length of 100. The polygon
procedure is provided as is starter code for the main part of the program. Add a loop and use it to call polygon
. Make sure that you draw everything from a 10-sided to a 3-sided polygon, counting down (10, 9, 8, … 3). Each shape should have a size (side length) of 100.
If you are having trouble, try printing out the loop counter so you can see which numbers your loop is counting through.
You have attempted
of
activities on this page.