Loops: for
for i in range(5):
print("Lap", i)Prints Lap 0 to Lap 4. range(5) gives 0, 1, 2, 3, 4: it starts at 0 and stops before 5.
Scratch: 'repeat 5'.
Topic 13 Programming basics
KS3 Computing · A program stores information in variables, works on it with operators, and controls the order with sequence, selection and iteration. Examples are in Python, with Scratch alongside for Year 7.
ProgrammingCambridge Lower Secondary Computing 0860
Say each word, then read what it means. Every one is in the glossary too.
Read it here, or open the study page below to go one step at a time with things to try.
for i in range(5):
print("Lap", i)Prints Lap 0 to Lap 4. range(5) gives 0, 1, 2, 3, 4: it starts at 0 and stops before 5.
Scratch: 'repeat 5'.
Open the study page and go one step at a time.
One question at a time. The reason shows after each answer.