Indefinite iteration: WHILE and REPEAT…UNTIL – AQA GCSE Computer Science lesson (8525)
Pupils learn to write indefinite iteration with the condition at the start (WHILE) or the end (REPEAT…UNTIL) and code both in the class's language.
Lesson 5 of 13 in unit 10.3 Binary, Logic and Iteration, taught in Year 10, Spring 1. It answers one big question: How can a program keep repeating until something changes?
By the end, pupils can write indefinite iteration with the condition at the start (WHILE) or the end (REPEAT…UNTIL) and code both in the class's language.
- The Build (the main task)
- Write a program that keeps asking the user to enter the PIN until the correct PIN, 4721, is entered, then outputs Door open. (5 marks) Explain one difference between a WHILE loop and a REPEAT…UNTIL loop. (2 marks)
- Support version
- Part-filled code with the WHILE condition given and the body to complete.
- Challenge
- Write the door lock algorithm in AQA pseudo-code using REPEAT…UNTIL. Then write it in the class's language so that it asks for the PIN at least once before checking it. (4 marks) The hub checks a backup battery. Write a program that keeps inputting battery levels (whole numbers) until a level of 20 or more is entered, then outputs how many levels were entered. (5 marks) Extend the door lock: the user has at most 3 tries. Write a program that stops asking when the PIN is right or after 3 tries, then outputs Door open if the PIN is right or Locked if not. (6 marks)
- Real-world link
- The smart door lock keeps asking for the PIN until it is right.
- Key words
- Indefinite iteration, Infinite loop and Predict, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “A WHILE loop always runs at least once”; “Every language has a REPEAT…UNTIL loop”.
- AQA 8525 specification
- 3.2.2 (programming concepts: definite, indefinite and nested iteration).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils need computers for the main task.
Also sold in the Binary, Logic and Iteration unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
Choose your school's Paper 1 language when you buy: C#, Python or VB.NET. You get that language's files: every program, code example, worked answer and programming task is written in it, and lessons with no code are the same in all three. Algorithms are also shown in AQA pseudo-code, as in the exam.
An independent resource written for AQA GCSE Computer Science (8525). It is not endorsed by AQA.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
- Your choice of Paper 1 language: C#, Python or VB.NET
More for GCSE Computer Science (AQA)
See allPupils learn to name the units from bit to terabyte with their symbols and values, and convert and compare quantities of bytes without a calculator.
Pupils learn to write definite iteration with FOR loops in the class's language and AQA pseudo-code, including STEP.
Pupils learn to explain why computers use binary and convert between binary and decimal from 0 to 255.
Written for the specifications named. Not endorsed by or affiliated with any exam board.