Turtle Challenge Six
Open tu5 and File, Save As, tu6
Changing a variable inside a loop
import turtle
t=turtle.Turtle()
wn=turtle.Screen()
lengthOfSide = 60 #initialise the variable
for i in range(20):
t.fd(lengthOfSide) #use the variable
t.rt(120)
lengthOfSide = lengthOfSide + 5 #add to the variable
wn.exitonclick()
Predict
Look at the code above, draw or describe what you think it will draw.
Run
Now run the code to see if you were right
Investigate
1, What is the name of the variable?
2, What is the starting value of the variable?
Screenshot the investigate questions (answers underneath)
Modify
5, Change the code to make it draw more sides. What did you change?
6. Change the code to draw the shape inside the starting line rather than outside the starting line. What did you change?
Screenshot the modify questions (answers underneath)
Make
Can you recreate one or both of these shown below?
Can you create your own pattern that uses a variable inside a loop?
Screenshot your code
Hex Spiral
Square Spiral
DEBUG your code if it doesn't work