🚀 Alguni Start learning

Unit 2: Straight Lines

Getting there, and getting back.

Unit 2 of 8 in Robotics coding for kids. Its 4 lessons are There and Back, The Square, Angles That Add Up and The Zigzag Run — below is everything each one explains, and a question or two from it to try.

Every program on this page was driven round the simulated room before it shipped, and prints exactly what it says it prints.

This unit is free for ever, because the first two units of every track are. Try it in the app.

🔁 There and Back

Reversing

robot.back(60) reverses 60 centimetres. The robot does not turn round first — it keeps facing the way it was, like a car backing out of a drive.

Python

robot.forward(60)
robot.back(60)
robot.say(robot.y())
robot.say(robot.heading())

It prints

150.0
0.0

Try it yourself

What is different about robot.back(50) and turning right twice then driving 50?

  • Backing up leaves the robot facing the same way it started
  • Nothing, they are the same
  • Backing up is twice as fast
  • Backing up does not count as moving

Answer it in the app

⬜ The Square

Four sides, four turns

A square is one instruction repeated: drive a side, turn a quarter. Four of those and the robot is back where it began, pointing the way it started.

Four turns of 90 make 360 — all the way round.

Python

robot.forward(50)
robot.right(90)
robot.forward(50)
robot.right(90)
robot.forward(50)
robot.right(90)
robot.forward(50)
robot.right(90)
robot.say(robot.heading())

It prints

0.0

Try it yourself

Bolt starts at 70, 150 and draws only three sides of a square. Where does it stop?

Python

robot.forward(50)
robot.right(90)
robot.forward(50)
robot.right(90)
robot.forward(50)
robot.say(robot.x(), robot.y())

Answer it in the app

📐 Angles That Add Up

Every closed shape turns 360

Walk right round anything and you end up facing the way you set off. That is one whole turn — 360 degrees — shared out between the corners.

A square has four corners, so 360 ÷ 4 = 90 each. A triangle has three, so 360 ÷ 3 = 120 each. Not 60, which is the angle *inside* the corner.

Python

robot.forward(70)
robot.right(120)
robot.forward(70)
robot.right(120)
robot.forward(70)
robot.right(120)
robot.say(robot.heading())

It prints

0.0

Try it yourself

How far should the robot turn at each corner of a six-sided shape?

  • 60
  • 120
  • 90
  • 360

What does this print?

Python

robot.right(120)
robot.right(120)
robot.say(robot.heading())

Answer them in the app

🏆 The Zigzag Run

Try it yourself

A robot drives a shape and finishes facing the way it started. What must its turns add up to?

  • 360, or a whole number of full turns
  • 180
  • 90
  • Anything at all

Answer it in the app