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

WHILE loops

301.10 Iteration

Practise exam questions

Iteration — Note 2 of 4

Repeat while condition true.

What you need to know

A while loop repeats as long as its condition is True. The condition is checked before each iteration. Use it when you don't know in advance how many times to loop.

What to know

  • while condition: repeats while True
  • Condition checked before each iteration
  • Must update something to eventually make condition False
  • If condition never becomes False → infinite loop

Code examples

WHILE loop
python
password = ""
while password != "secret":
    password = input("Enter password: ")
print("Access granted")
← Previous noteFOR loops301.10 IterationNext note →Loop patterns301.10 Iteration

Back to Iteration

Specification notes for programming are in Paper 2.

Iteration

Note 2 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).