The Turtle Stamp Procedure¶
You can change the shape of the turtle using the shape
procedure. In the
program below we set it to look more like a turtle.
A turtle can also stamp a copy of itself on the screen (turtle drawing
area), and this will remain after the turtle has moved somewhere else. Do this
with the stamp
procedure. Stamping works even when the pen is up. You can
ask the turtle to pick up the pen using the up
procedure as shown below.
When the pen is up the turtle will not draw a line when it moves.
Here is an example that shows off these new features.
The list of integers shown under the picture above is created by printing the
range(5,60,2)
result. This shows you the distances used to move the turtle
forward each time through the for
loop.
All except one of the shapes you see on the screen here are copies of the
turtle shape created by stamp
. But the program still only has one turtle
instance — can you figure out which one is the real tess? (Hint: if you’re
not sure, write a new line of code after the for
loop to change tess’
color, or to put her pen down and draw a line, or to change her shape, etc.)
Mixed up program
csp-10-4-2: csp-10-4-1: The following program uses the stamp method to create a line of turtle shapes as shown to the left, 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. Then the turtle should repeat the following three times: go forward 50 pixels and leave a copy of the turtle at the current position.
Drag the needed blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on Check Me to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks.
from turtle import *
space = Screen()
space.setup(400,400)
---
nikea = Turtle()
---
nikea.shape("turtle")
---
nikea.shape(turtle) #paired
---
nikea.penup()
---
nikea.penUp() #paired
---
for size in range(3):
---
for size in range(3) #paired
---
nikea.forward(50)
---
nikea.stamp()
---
nikea.stamp #paired
csp-10-4-4: csp-10-4-3: The following program uses the stamp method to create a circle of turtle shapes as shown to the left, 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. Then the turtle should repeat the following ten times: go forward 50 pixels, leave a copy of the turtle at the current position, reverse for 50 pixels, and then turn right 36 degrees.
Drag the needed blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on Check Me to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks.
from turtle import *
space = Screen()
jose = Turtle()
---
jose.shape("turtle")
jose.penup()
---
jose.shape("turtle")
jose.penup #paired
---
for size in range(10):
---
for size in range(10) #paired
---
jose.forward(50)
---
jose.stamp()
---
jose.Stamp() #paired
---
jose.forward(-50)
---
jose.forward(-25) #paired
---
jose.right(36)
---
jose.right(20) #paired