Skip to main content
Menu
Lesson 2: Basic Shapes
Back to Turtle Coding
Lesson 2 of 7

4 Drawing a square

In Lesson 1 you used t.forward() and t.right() to draw an L-shape. A square has 4 equal sides, so we write the same pair of instructions 4 times — once for each side.

Edit the code, then click Run

Try it:

Count the t.forward(100) lines. How many are there?

Change all four 100s to 60. Click Run. Is it still a square?

5 Drawing a rectangle

A rectangle has two long sides and two short sides. We still write 4 forward-and-turn steps, but the forward numbers alternate between long and short.

Edit the code, then click Run

Your turn:

Change the 150s to 200
and the 80s to 40

Click Run
Is it still a rectangle?

Now make all four numbers the same
What shape do you get?

6 Drawing a triangle

A triangle has 3 corners, so we need 3 forward-and-turn steps.
The turn is bigger than 90°. It is t.right(120)

Edit the code, then click Run

Your turn:

Change all three 120s to 90
Click Run
Does the triangle close?

Now change them back to 120

7 Circles: a shortcut

Drawing a circle out of straight lines would take a lot of code. Turtle has a shortcut built in: t.circle(radius) draws a whole circle in one line.

Edit the code, then click Run

Try it:

Change 60 to a bigger number, then a smaller number.

What does the number inside circle() control?

8 Now you try: three shapes

Draw each shape in its own window.

1. Square

A square has 4 sides.

Type your code, then click Run
Hint

Do t.forward(100) then t.right(90).
Type those two lines 4 times.

2. Triangle

A triangle has 3 sides.

Type your code, then click Run
Hint

Do t.forward(100) then t.right(120).
Type those two lines 3 times.

3. Circle

A circle needs just one line.

Type your code, then click Run
Hint

Type t.circle(60)
Try a different number.

What you learned in this lesson

  • a shape’s sides are drawn with t.forward() and t.right(), one pair per side
  • a shape with n equal sides turns 360° ÷ n at each corner
  • a square turns 90°, a triangle turns 120°
  • t.circle(radius) draws a circle in a single line
  • t.penup() and t.pendown() let you move the turtle without drawing

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.

Certificate of Achievement

Well done!

This certificate is awarded to

for completing Turtle Coding

Lesson 2: Basic Shapes

You have:

  • drawn a square, a rectangle and a triangle
  • used t.circle() to draw a circle
  • moved the turtle with penup and pendown
Date:
Keep coding!
Teacher signature
Helpful?