Decisions and loops · GCSE · OCR J277 2.2.1, AQA 8525 3.2.2, Edexcel 1CP2 6.2.1 · about 10 min
How Python groups lines: the colon and the indent.
[1 mark]What does this program print?
if True:
print("one")
print("two")
print("three")[1 mark]What must a line that starts a block end with?
:;()[1 mark]What does Python say about a line indented for no reason, with no : line above it?
[1 mark]Two lines in the same block are indented by four spaces and three spaces. What happens?
[1 mark]How many spaces is the usual indent for a block inside a block?
[1 mark]Where does a block end?
[1 mark]In OCR's Exam Reference Language, which word closes an if block?
This program's lines are in the right order but the indentation is wrong. It should print inside the block, then leave the LED green, then print after the block once. Fix only the spaces.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
if True:
print("inside the block")
# the LED: green
led("green")
print("after the block")Plan your program here, then type it in and press Run.