ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Selection/Switch and case
J277 · 2.2.1

Unit 6 · Lesson 4

Switch and case

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Read and write exact OCR switch/case syntax and translate it into Python if/elif/else.

OCR ERL uses switch/case for a multi-way choice based on one value. Put a colon after the switch expression, each case value and default. Only the matching case runs; default handles unmatched values. This is selection, not iteration. Python can express the same beginner-level decision with if/elif/else.

switch

A selection structure that checks one expression against several possible values.

case

One value that may match the switch expression and select its instructions.

default

The fallback branch used when no case value matches.

endswitch

The OCR ERL keyword that closes a switch structure.

Keep these in mind

  • The exact ERL opening form is switch expression :.
  • Each case is followed by a value and a colon.
  • default has no comparison value and handles every unmatched case.
  • Close the complete structure with endswitch.
  • OCR ERL cases do not need a break instruction.

Learning objective

Read and write exact OCR switch/case syntax and translate it into Python if/elif/else.

Exam tip

If asked to classify switch/case, answer selection. It compares values and chooses one branch; it does not repeat instructions.

Common mistake

Do not write case choice == 1 or add break. The switch already names the expression, so an ERL case contains only its matching value followed by a colon.

PreviousNext