Note 20.5.1.
The one-parameter range recipe
range(10) is the same as the three-parameter recipe range(0, 10, 1).
polygon:
...
polygon(mia, 6, 100)
polygon(mia, 5, 100)
polygon(mia, 4, 100)
polygon(mia, 3, 100)
polygon(mia, sides, 100) where sides is set to the values 6, 5, 4, 3 in successive calls.
x and is used to count from 0 to 4. In the second, the loop variable is called y and counts from 0 to 9.
polygon example, to count from 6 down to 3? Or to count from 10 to 100 by 10’s? To do these tasks, we can use a three-parameter version of range:
range(startValue, stopValue, step)
range begins from the startValue, increases by step with each value, and stops when it hits stopValue (but does not actually include the stopValue). If the step is negative, range will count down from startValue to stopValue .
range(10) is the same as the three-parameter recipe range(0, 10, 1).
stamp procedure to leave a copy of itself on the screen that will remain after the turtle has moved somewhere else. It also uses the shape procedure to change the turtle’s icon from the default triangle to an actual turtle.
for size in range(5, 60, 2):, says to count by 2’s from 5 to 59. The loop variable is called size and is used to control how far forward the turtle moves in each repetition.
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…)