Programming for Children
Primary 6 · Science and Elementary Technology
Programming for Children
Lesson 2 of 6
30 min
Let's begin
Ishimwe wants the turtle to draw an equilateral triangle. He remembers that each corner of an equilateral triangle is 60°, so he writes repeat 3 [forward 100, right 60]. But the turtle draws half of a hexagon and stops far away from where it started. What went wrong? Today you will find out, then use lines and angles to make shapes that look 3D.
The angle inside the corner of an equilateral triangle is 60°. But the turtle does not turn by the inside angle. It is walking straight, and at the corner it must turn by the angle outside the shape:
turning angle = 180 − inside angle
equilateral triangle: 180 − 60 = 120
Check: 3 turns × 120° = 360°, a full circle. So the correct program is:
repeat 3
forward 100
right 120
Let us draw a right-angled triangle with two equal sides. Its inside angles are 90°, 45° and 45°. The turns are:
Check: 90 + 135 + 135 = 360. ✔
forward 100
right 90
forward 100
right 135
forward 141
right 135
Why 141? The slanting side (the one opposite the right angle) is always the longest. On paper, draw two lines of 10 cm at a right angle with your ruler and protractor, then measure the slanting side: it is about 14.1 cm. So in steps, 100 and 100 give a slanting side of about 141.
A screen is flat, but we can trick the eye into seeing depth. The trick: draw the front face, draw the back face the same size but moved up and to the right, then join the matching corners with slanting lines.
A cube (all faces are squares). Start at the bottom-left corner, pen down, facing up:
A cuboid is the same, but the faces are rectangles: repeat 2 [forward 60, right 90, forward 120, right 90].
A cylinder has an oval top and bottom joined by two straight sides. Turtle Blocks has an arc block that turns while it moves. Four arcs make a flattened circle (an oval):
repeat 2
arc 90, radius 20
arc 90, radius 60
Draw one oval for the top, draw two straight lines down from its left and right edges, and draw another oval (or its front half) at the bottom. You can colour each face a different shade to make the depth even clearer.
Tip
Turtles turn the OUTSIDE angle. Turn = 180 − inside angle. And all the turns in any closed shape add up to 360.
Answers
What you learned today
Sources and credits
Written by Ganzaa. Turtle Blocks is free software from Sugar Labs.
Quick check