Python quick start · Robot club · about 12 min
for and while, indentation, and a square drawn with three lines instead of eight.
[1 mark]What does this program print?
for i in range(4):
print("this is time number", i)[1 mark]What does this program print?
for i in range(3):
print("side")
print("done")[1 mark]What does this program print?
for i in range(3):
print(i * 10)[1 mark]What does this program make the robot do?
for i in range(4):
forward(50, distance=25)
turn_right(35, angle=90)
stop()[1 mark]You want the robot to drive a triangle with equal sides. How many degrees should turn_right turn at each corner?
[1 mark]The robot starts at heading 0 and runs turn_right(35, angle=90) three times. Ignoring small errors, what does heading() say? Give a whole number of degrees.
[1 mark]Why does a while loop that drives need a small wait() inside it?
Drive a square: 30 cm a side, turning right at each corner, using a for loop. The four green squares are the corners it has to pass through.
from bugbot import *
connect()
for i in range(4):
# one side and one corner
forward(50, distance=30)
stop()Plan your program here, then type it in and press Run.
turn_left.for loop, led("red"), wait(0.2), led("off"), wait(0.2).