CODE TT3
Step 1: Make all the "turtle" commands available to us.
import turtle
Step 2: Move in the direction turtle's facing for 50 pixels
turtle.forward(50)
Step 3: We're done! This keeps the window open until we close it.
turtle.done()
If you use this new command then you should be able to make a square.
turtle.right(90)
For LoopsThere are some important things to know about Python. Let's have a look at this code:
for i in range (4):
print(i)
The for command tells us that we are going to make a loop. You need to use tab to indent the second line and the colon is very important. It then prints the number.
Now let's use the same idea for a square:
import turtle
for i in range (4):
turtle.forward(50)
turtle.right(90)
import turtle
Step 2: Move in the direction turtle's facing for 50 pixels
turtle.forward(50)
Step 3: We're done! This keeps the window open until we close it.
turtle.done()
If you use this new command then you should be able to make a square.
turtle.right(90)
For LoopsThere are some important things to know about Python. Let's have a look at this code:
for i in range (4):
print(i)
The for command tells us that we are going to make a loop. You need to use tab to indent the second line and the colon is very important. It then prints the number.
Now let's use the same idea for a square:
import turtle
for i in range (4):
turtle.forward(50)
turtle.right(90)
Exercise 1: Please could you adjust the code to make an 8 sided shape.