Python quick start · Robot club · about 12 min
if, else, comparisons, and a robot that looks with distance() before it moves.
[1 mark]What does this program print?
gap = 25
if gap > 30:
print("plenty of room")
else:
print("too close")[1 mark]What does this program print?
gap = 30
if gap > 30:
print("go")
else:
print("stop")[1 mark]Which line asks whether gap is 15?
if gap == 15:if gap = 15:if gap is equal 15:if 15:[1 mark]What does this program make the robot do?
while distance() > 15:
forward(40)
wait(0.1)
stop()[1 mark]The same program runs with the robot already 10 cm from the wall. What happens?
while distance() > 15:
forward(40)
wait(0.1)
stop()[1 mark]gap is 20. Which of these tests are true?
Tick every answer that is true.
gap > 15gap >= 20gap != 20gap < 20gap == 20[1 mark]Which two symbols together mean "is not" in Python?
Drive up to the wall and stop between 10 cm and 20 cm from it, without touching it. Look as you go, rather than guessing a distance.
from bugbot import *
connect()
while distance() > 40:
forward(40)
wait(0.1)
stop()
print("gap", distance())Plan your program here, then type it in and press Run.