Driving · Robot club · about 15 min
turn_left() and turn_right() by an angle, heading() as a compass, and turning on the spot.
[1 mark]Which way does turn_right(30, angle=90) turn the robot, seen from above?
[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.
[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.
[1 mark]What does turn_right(40) do, with no angle?
[1 mark]A pentagon has five equal sides. What angle should each turn_right be? Give a whole number of degrees.
[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.
for side in range(4): turn_right(30, angle=90)from bugbot import *connect() forward(60, distance=25)print("home?", position())[1 mark]After driving a square, the robot is a little away from its start and a few degrees off. Why?
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.
sides.turn_left(30) with no angle and a while loop to stop when heading() is close to 270.