What is a turtle?
In Python, a turtle is a little arrow, not a real animal.
It walks around the screen and draws a line behind it, like a pen.
We tell it where to go with code, and it draws a picture!
How to use the code box
- On the left of the black box below: type your code.
- On the right: a white screen where the turtle will draw.
- Click the orange Run button to see what your code does.
- If you want to start again, click Reset.
1 Your very first line of code
Some code is already waiting for you below.
Click Run and watch what happens.
Try it:
Change the number 100 to 50.
Click Run.
Now change it to 200.
Click Run again.
What changes?
2 Teaching the turtle to turn
Predict first: the turtle walks forward, turns, then walks forward again.
Which way will it go after the turn? Click Run to check.
t.right(90) turns the turtle a quarter-turn to the right, like turning a corner.
Your turn:
Change 90 to 45
What changed?
Now try 180
Where does the turtle go?
Change right toleft
3 Now you try: draw an L-shape
Using just t.forward() and t.right(), write code that makes the turtle draw the letter L. Remember: put a number between the brackets each time, like t.forward(100) and t.right(90).
Hint 1
Start with the top line. Type this under t = turtle.Turtle():t.forward(100)
Hint 2
Now the slanting line. Add these two lines:t.right(135)t.forward(140)
Hint 3
Last, turn back and draw the bottom line. Add these two lines:t.left(135)t.forward(100)
Plan it first. Which way does the turtle turn for the slanting line? Is the turn bigger or smaller than 90? Try different numbers until it looks right.
What you learned in this lesson
import turtlebrings in the turtle toolt.forward(steps)moves the turtle and draws a linet.right(degrees)turns the turtle- 90° makes a right-angle turn, like the corner of a square
Your certificate is locked
Go back and try the code boxes.
Change the code, click Run, and do this in at least 2 code boxes to unlock your certificate.
Well done! Type your name, check your certificate, then press Print.
Well done!
This certificate is awarded to
for completing Turtle Coding
Lesson 1: Meet the Turtle
You have:
- written your very first line of Python
- made the turtle move forward and turn right
- drawn an L-shape all by yourself