The answersDownload the PDF
Worksheet

1.3 Turning and heading

Driving · Robot club · about 15 min

BugBotLab
NameClassDate

What this lesson is about

turn_left() and turn_right() by an angle, heading() as a compass, and turning on the spot.

Questions 7 marks in all

  1. [1 mark]Which way does turn_right(30, angle=90) turn the robot, seen from above?

    1. AClockwise, the way a clock's hands go
    2. BAnticlockwise
    3. CIt slides right without turning
    4. DIt depends on which way the robot is facing
  2. [1 mark]The robot starts at heading 0 and runs turn_left(30, angle=90). What does heading() say? Give a whole number of degrees.

  3. [1 mark]From heading 0 the robot turns right 90, right 90 again, then left 45. What does heading() say? Give a whole number of degrees.

  4. [1 mark]What does turn_right(40) do, with no angle?

    1. AStarts turning clockwise and keeps turning until the next command
    2. BTurns 40 degrees and stops
    3. CTurns a quarter turn at speed 40
    4. DNothing, because it needs an angle
  5. [1 mark]A pentagon has five equal sides. What angle should each turn_right be? Give a whole number of degrees.

  6. [1 mark]Put these lines in order to drive a square: each time, drive a side, then turn.

    Number the lines 1 to 6 to put them in the right order.

    1. for side in range(4):
    2. turn_right(30, angle=90)
    3. from bugbot import *
    4. connect()
    5. forward(60, distance=25)
    6. print("home?", position())
  7. [1 mark]After driving a square, the robot is a little away from its start and a few degrees off. Why?

    1. AThe small errors in each move add up
    2. Brange(4) only does three sides
    3. Cturn_right cannot do exactly 90
    4. Dposition() is reset at each corner

The task: face east

Turn so the robot faces 90 degrees (to the right of where it started), then print facing: and its heading. Do not drive anywhere.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

# turn 45 degrees clockwise, then stop
turn_right(30, angle=45)
print("facing:", heading())

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/1-3-turning/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Draw a triangle, then a pentagon, with the same loop and a different sides.
  2. Turn 360 in four steps of 90 and print the heading after each. How far off is the last one?
  3. Use turn_left(30) with no angle and a while loop to stop when heading() is close to 270.