ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Iteration/Do-until and input loops
J277 · 2.2.1

Unit 7 · Lesson 4

Do-until and input loops

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Interpret OCR do/until and translate its post-test behaviour into Python.

OCR do/until runs the body first and checks its condition afterwards, so it always executes at least once. Python has no direct do-until statement. A faithful translation uses while True, performs the body, and breaks when the ERL until condition becomes true.

do-until loop

A post-test loop that repeats until its condition becomes true.

Post-test

Checking a stopping condition after the loop body has executed.

Sentinel value

A special input value used to signal that repetition should stop.

break

A Python statement that immediately leaves the nearest loop.

Keep these in mind

  • The until condition is a stopping condition, not a continuing condition.
  • The body always runs before the first check.
  • Python while True with a conditional break can preserve the same order.
  • Input that may change the stopping condition belongs inside the repeated body.

Learning objective

Interpret OCR do/until and translate its post-test behaviour into Python.

Exam tip

Do not reverse the meaning of until. ERL until answer == Correct stops when equality becomes true.

Common mistake

Checking answer != Correct before break stops on the wrong input. The break condition must match the ERL until condition.

PreviousNext