Programming basics · GCSE · OCR J277 2.2.3, AQA 8525 3.2.10, Edexcel 1CP2 6.6.1 · about 15 min
Arguments, telling and asking, and notes on the robot's buzzer.
[1 mark]In led("red"), what is "red" called?
[1 mark]What happens when a program contains stop with no brackets?
[1 mark]Which of these functions ask the robot something and give back an answer?
Tick every answer that is true.
battery()distance()led("red")stop()[1 mark]A program has the line battery() on its own. What does it show?
[1 mark]In forward(50, distance=20), what is distance=20 called? (two words)
[1 mark]led(255, 0, 0) makes the LED red. What does led(0, 0, 255) make it?
[1 mark]tone(440, 0.5) plays a note. What does the 0.5 set?
[1 mark]battery() gives back a value and led("red") does not. In exam terms, which is a function and which is a procedure?
Make the LED blue, then print two lines: battery: <number> and ahead: <number>, using the robot's answers. The robot must not drive.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
led("...")
print("battery:", ...)The hint students can ask for: Set the LED first, then print the two sensor readings on their own lines, worded as the task shows. Nothing here needs the robot to move.
from bugbot import *
connect()
led('blue')
print('battery:', battery())
print('ahead:', distance())
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.