Single lesson · Written for OCR J277

Condition-controlled loops (WHILE, DO UNTIL) – OCR GCSE Computer Science lesson (J277)

Pupils learn to write WHILE loops that stop when a condition changes, trace DO UNTIL loops in OCR Exam Reference Language, and spot infinite loops.

Also in a bundle Binary, Boolean Logic and Iteration – OCR GCSE Computer Science lessons (J277) 11 lessons for £39 · save 11% on buying separately

Lesson 5 of 11 in unit 10.3 Binary, Boolean 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 WHILE loops that stop when a condition changes, trace DO UNTIL loops in OCR Exam Reference Language, and spot infinite loops.

The Build (the main task)
Write a Python program for the smart door lock that uses a WHILE loop (a condition-controlled loop) to keep asking for the PIN until 4721 is entered, printing 'Wrong PIN' after each wrong try, then prints 'Door unlocked'.
Support version
Parsons problem: jumbled lines with an if distractor that only asks twice.
Challenge
Lock out after three wrong PINs, using a counter and a combined condition.
Real-world link
The smart door lock keeps asking for the PIN until the right one is entered.
Key words
Condition-controlled loop, 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, even if its condition starts False”; “An infinite loop is a syntax error that the computer will spot”.
OCR J277 specification
2.2.1 (programming fundamentals: iteration – count-controlled loops (FOR) and condition-controlled loops (WHILE, DO UNTIL); Boolean operators in conditions).

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, Boolean Logic and Iteration unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.

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

More for GCSE Computer Science (OCR)

See all

Written for the specifications named. Not endorsed by or affiliated with any exam board.