Community resourceWorksheet

OCR H446 2.2.1 Control structures in OCR and Python

Part 1 of 14 · H446 2.2.1 · Programming techniques

OCR H446 2.2.1 expects students to move between OCR's exam reference language and Python, where the same loop can carry different boundaries. This worksheet builds the sequence, selection and iteration model first, makes the FOR and range boundary difference explicit, then asks students to construct control flow from a stated requirement.

Students will:

  • identify sequence, selection and iteration in a described requirement
  • translate OCR exam reference language loop boundaries into the equivalent Python range
  • trace a timetable algorithm and record how its state changes on each pass
  • write Python selection that assigns values across several discrete cases
  • recommend a loop type when the number of attempts is not known in advance and justify it

Inside: 7 explanation cells, 2 multiple-choice questions, 1 fill-in-the-blanks cell, 2 written answers, 2 Python tasks and 1 trace table. 16 marks, about 35 to 50 minutes.

Series: H446 2.2.1 · Programming techniques, part 1 of 14.

Shared by Coding PathwayVerified teacher

  • 15 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 31 Aug 2026
  • Updated 1 Oct 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

Control structures in OCR and Python

Control structures determine the order in which a program runs its instructions. Sequence runs instructions in order. Selection chooses a route from a True or False condition. Iteration repeats instructions. The examples use OCR Exam Reference Language (ERL) and Python so that you can compare behaviour before concentrating on syntax.

By the end, you will be able to

  • identify sequence, selection and iteration
  • use IF, ELSEIF, ELSE and switch/case selection
  • distinguish count-controlled and condition-controlled iteration
  • read, trace and write equivalent OCR ERL and Python structures

One idea, different notation

BehaviourOCR ERLPython
choose between routesIF ... THEN / ELSEIF / ELSE / ENDIFif / elif / else with indentation
select from named valuesswitch ... case ... defaultmatch ... case, or if / elif
repeat a known number of timesFOR i = 1 TO 5 ... NEXT ifor i in range(1, 6):
test before each repetitionWHILE ... ENDWHILEwhile ...:
run once, then testREPEAT ... UNTIL conditiona loop arranged so the test occurs after the first pass

A FOR loop is normally count-controlled. WHILE and REPEAT-UNTIL are condition-controlled, but a condition-controlled loop can still imitate a count loop by using an initial counter, a condition and an update. Always read the stated language carefully: OCR's FOR upper bound is included, while Python's range stop value is excluded.

Worked model: decide the behaviour first

Requirement: process slots 1 to 4 and add the even slot numbers.

OCR ERL uses FOR slot = 1 TO 4, so 4 is included. Python needs range(1, 5) because 5 is excluded. Both versions visit 1, 2, 3 and 4.

The same count could be controlled by a condition:

slot = 1
while slot <= 4
    ...
    slot = slot + 1
endwhile

This works only if the counter is initialised, tested and updated correctly. A FOR loop expresses this fixed count more directly.

Choice routine: Does it choose a route? → selection. Is the number of repetitions known? → FOR. Is repetition controlled by a changing condition? → WHILE or REPEAT-UNTIL. Must the body run at least once? → REPEAT-UNTIL.

Worked example: selection with switch/case

Use switch/case when one expression is compared with several discrete values. OCR ERL writes switch zone: followed by labelled cases and an optional default. In suitable Python versions, match zone: with case clauses expresses the same decision shape; an if/elif chain is also a valid Python implementation.

switch zone:
    case "stage":
        fee = 12
    case "workshop":
        fee = 8
    default:
        fee = 0
endswitch

For zone = "workshop", the second label matches, so fee becomes 8 and the other routes do not run. default handles values that match no named case.

Written answer4 marks

Write the Python selection that assigns the same fees using match/case or an equivalent if/elif/else chain.

Cover stage, workshop and the default outcome. Preserve the three fee values.

Students type their answer here.

Multiple choice1 mark

Which description best defines sequence?

  • AExecuting instructions in a stated order
  • BChoosing one path from several
  • CRepeating instructions until a condition
  • DCalling a function from itself
Trace table6 marks

Trace this OCR ERL timetable algorithm.

Enter a value only when it changes. Keep the listing's order.

Use one row for each pass through the loop. Fill in a box only when that value changes on that row, and leave the rest blank.

AlgorithmExam reference language
  1. total = 0
  2. for slot = 1 to 4
  3. if slot MOD 2 == 0 then
  4. total = total + slot
  5. else
  6. total = total + 1
  7. endif
  8. next slot
  9. print(total)
Trace table with 4 columns
Rowtotalslotslot MOD 2 == 0Output
1
2
3
4
5
6
7
8
Multiple choice1 mark

A queue check must run at least once and then repeat until the queue is empty. Which structure most directly expresses this?

  • AFOR loop
  • BREPEAT-UNTIL loop
  • CWHILE loop
  • DSwitch/case
Worked example
age = 17
has_pass = True
if age >= 16 and has_pass:
    zone = "stage"
elif age >= 16:
    zone = "help desk"
else:
    zone = "family area"
print(zone)

Write a festival rule

Complete the function. Return 'full' when capacity is zero or less, 'few' when fewer than 10 places remain, and 'open' otherwise.

Coding task4 marks
def entry_status(places_remaining):
    pass
Written answer2 marks

A ticket scanner must ask for a code at least once and keep asking until the code is valid. Recommend a loop structure and justify it.

State when the condition is checked and connect that timing to the required first attempt.

Students type their answer here.

Checkpoint

Complete the control-structure summary from memory. There is no answer bank, and correctness is withheld until teacher review.

Fill in the blanks4 marks
Instructions executed in a stated order use checkpoint gap 1. Choosing a route uses checkpoint gap 2. A FOR loop is normally checkpoint gap 3 controlled, while WHILE and REPEAT-UNTIL are checkpoint gap 4 controlled.

Review your understanding

Before submitting, check that you can explain the main distinction in your own words, apply it in an unfamiliar context and justify the resulting behaviour or consequence.