Python quick start · Robot club · about 10 min
The two lines at the top, drive, wait, stop, print, and the rule that stops the robot on its own.
[1 mark]What does connect() do?
from bugbot import * brings in the commands, and connect() gets you the robot itself. You need both lines at the top.[1 mark]What does forward(50) do on its own?
forward(50) only starts the robot going. It does not wait, which is why you need wait() to let it drive for a while.[1 mark]This program has no stop(). What does the robot do?
from bugbot import * connect() forward(60) wait(1.5)
[1 mark]Put these lines in order to drive forward for two seconds, stop, and then say so.
Number the lines 1 to 6 to put them in the right order.
connect()wait(2)from bugbot import *forward(50)print("done")stop()from bugbot import *
connect()
forward(50)
wait(2)
stop()
print("done")The two setup lines always come first. Then start driving, let time pass, switch the motors off, and only then print that you have finished.
[1 mark]What does this program print?
print("drove for", 2, "seconds")drove for 2 seconds
Commas in print() put a single space between each thing, whether it is text or a number.
[1 mark]Which of these make BugBot move across the mat?
Tick every answer that is true.
forward(60)right(60)led("green")backward(60)print(position())forward, backward and right drive the robot. led only changes the light, and print only writes a line.[1 mark]You drive forward for 1 second and back for 1 second. Why does position() not say exactly (0, 0)?
Drive from the start into the green zone and stop inside it, using forward, wait and stop.
If it stops short, wait longer or drive faster.
from bugbot import * connect() forward(50) wait(1) stop()
The hint students can ask for: The green zone starts 40 cm ahead. Drive long enough, or fast enough, to get there, then stop inside it.
from bugbot import * connect() forward(60) wait(4) stop()
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.