Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/Iteration

FOR loops

301.10 Iteration

Practise exam questions

Iteration — Note 1 of 4

Repeat N times.

What you need to know

A for loop repeats a block a fixed number of times. Use range() to generate the sequence of values for the loop variable.

What to know

  • for i in range(n): repeats n times, i = 0,1,...,n-1
  • range(1, 6) gives 1 to 5; range(0, 10, 2) steps by 2
  • Loop variable updates each iteration automatically
  • Use for when you know how many repetitions

Code examples

FOR loop with range
python
for i in range(5):
    print(i)      # 0 1 2 3 4

for i in range(1, 4):
    print(i * 2)  # 2 4 6
← Previous topicMatch Case301.9 SelectionNext note →WHILE loops301.10 Iteration

Back to Iteration

Specification notes for programming are in Paper 2.

Iteration

Note 1 of 4

  1. 1FOR loops
  2. 2WHILE loops
  3. 3Loop patterns
  4. 4Loop bugs
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).