1. Predict
2. Investigate
3. Modify
A
B
Which instructions need to be repeated to get the below image?
# How many times
# must I repeat?
for i in range(?):
# instruction 1
# instruction 2
# ...
tina.hideturtle()2. Modify
3. Challenge
hint: tina.color("blue")
def donow():
tina = turtle.Turtle()
tina.shape("arrow")
tina.color("teal")
tina.forward(50)
tina.penup()
tina.goto(0,50)
tina.pendown()
tina.forward(50)
tina.penup()
tina.goto(0,-50)
tina.pendown()
tina.forward(50)
donow()def donow():
tina = turtle.Turtle()
tina.shape("arrow")
tina.color("teal")
tina.forward(50)
tina.penup()
tina.goto(0,50)
tina.pendown()
tina.forward(50)
tina.penup()
tina.goto(0,-50)
tina.pendown()
tina.forward(50)
tina.color("red")
tina.goto(50,50)
tina.penup()
tina.goto(0,50)
tina.pendown()
tina.goto(0,-50)
donow()for i in range(n):
makes a loop that repeats
indented instructions
exactly n times.
A
B
C
D
3. Challenge
1. Predict
2. Modify
3. Challenge
2. Modify
def square():
tina = turtle.Turtle()
tina.shape("square")
tina.color("maroon")
tina.penup()
tina.goto(-50,-50)
tina.pendown()
for i in range(4):
tina.forward(100)
tina.left(90)
square()def square():
tina = turtle.Turtle()
tina.shape("square")
tina.color("maroon")
tina.penup()
tina.goto(-50,-50)
tina.pendown()
for i in range(4):
tina.forward(100)
tina.left(90)
tina.penup()
tina.goto(-100,-100)
tina.color("purple")
tina.pendown()
for i in range(4):
tina.forward(200)
tina.left(90)
square()for i in range(n):
makes a loop that repeats
indented instructions
exactly n times.
A
B
C
D
3. Challenge
1. Predict
2. Modify
3. Challenge
2. Modify
def triangle():
tina = turtle.Turtle()
tina.shape("classic")
# GREEN TRIANGLES
tina.color("green")
for i in range(3):
tina.forward(25)
tina.left(120)
for i in range(3):
tina.forward(50)
tina.left(120)
for i in range(3):
tina.forward(75)
tina.left(120)
# RED TRIANGLE
tina.color("red")
for i in range(3):
tina.forward(25)
tina.right(120)
for i in range(3):
tina.forward(50)
tina.right(120)
for i in range(3):
tina.forward(75)
tina.right(120)
triangle()while True:
makes a loop that repeats
indented instructions
forever ♾️
Let's modify the code to make our first spiral like below.
Click for Square Spiral
Click for Triangle Spiral (part 1)
Click for Triangle Spiral (part 2)
while True:
makes a loop that repeats
indented instructions
forever ♾️
Make your own spiral by changing the side and angle values, the colors and shape.
Hint: Change the speed to tina to 0 (the max)
tina.speed(0)
Challenge
How was I able to do a reverse spiral like in the gif below?