Community resourceWorksheet

OCR H446 1.2.4 Procedural languages: read, trace, amend and write

Part 2 of 10 · H446 1.2.4 · Types of programming language

Procedural programming is examined through working code, so H446 1.2.4 rewards students who can follow state rather than recite a list of features. This worksheet works one small parameterised routine hard, tracing it, amending it against a new requirement and then writing a fresh procedure from a specification.

Students will:

  • trace variables, a loop condition, a running total and the returned value through a parameterised call
  • explain why a total is initialised before the loop that adds to it
  • choose between count-controlled and condition-controlled iteration from what governs the repetition
  • amend a routine's comparison and selection logic, then predict the strings it returns
  • write and test a procedure that counts exact matches in a list, including an empty or no-match case

Inside: 6 explanation cells, 2 multiple-choice questions, 1 fill-in-the-blanks cell, 2 written answers and 1 trace table. 21 marks, about 40 to 50 minutes.

Series: H446 1.2.4 · Types of programming language, part 2 of 10.

Shared by Coding PathwayVerified teacher

  • 12 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 31 Aug 2026
  • Updated 3 Sept 2026

Preview

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

Procedural languages: read, trace, amend and write

Procedural programming is learned by following and changing state, not by memorising a list of features. This worksheet uses sequence, selection, iteration, a parameterised subroutine, strings and Boolean/arithmetic operations.

Read the program as a state story

def label_score(name, scores, limit):
    total = 0
    for score in scores:
        if score >= limit:
            total = total + score
    return name + ':' + str(total)

print(label_score('Asha', [3, 8, 6], 6))
  • Inputs arrive through parameters.
  • total is local state initialised before iteration.
  • Selection decides which values affect the state.
  • The return combines a string with the final arithmetic result.

For the call shown, 3 is rejected, then 8 and 6 are accumulated, so the returned string is Asha:14. A trace records changes; it does not merely paraphrase the code.

Trace table14 marks

Complete the state trace for the supplied call. Track score, the condition, total, returned value and printed output.

Record values only when they change. Record outputs in order and include the terminating state.

Use one row for each statement as it runs. Fill in a box only when that value changes on that row, and leave the rest blank. Put the line number from the listing in the Line column.

ProgramPython
  1. def label_score(name, scores, limit):
  2. total = 0
  3. for score in scores:
  4. if score >= limit:
  5. total = total + score
  6. return name + ':' + str(total)
  7. print(label_score('Mina', [5, 9, 4, 7], 7))
Trace table with 9 columns
RowLinename (label_score)scores (label_score)limit (label_score)total (label_score)score (label_score)Return valuescore >= limitOutput
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Multiple choice1 mark

Why is total = 0 placed before the loop?

  • ATo make every score zero
  • BTo reset the running total once for this call
  • CTo replace the selection
  • DTo turn the list into a file

Choose iteration from what controls repetition

Use count-controlled iteration when the number of repetitions is known before the loop, such as processing exactly five readings. Use condition-controlled iteration when repetition continues until a Boolean condition changes, such as accepting values until a valid code is entered. A for or while keyword is evidence only when its control rule matches the problem.

Multiple choice1 mark

A program must keep requesting a password until the supplied valid(password) function returns true. Which control is most appropriate?

  • ACount-controlled iteration because every loop must have a fixed number of attempts
  • BSelection without any repetition
  • CCondition-controlled iteration because the number of attempts is not known in advance
  • DA subroutine declaration that runs automatically

Guided amendment

New requirement: include scores strictly above the limit and add a ! only when the total exceeds 20. Change >= to >. After the loop, use selection to return either name + ':' + str(total) + '!' or the version without !.

Check the boundary case score == limit; it must now be excluded. Boundary tests reveal whether a changed comparison really meets the new requirement.

Written answer7 marks

Describe the exact code changes and predict the returned strings for label_score('Noor', [7, 8, 13], 7) and label_score('Ivo', [7, 8, 12], 7) after the amendment.

Show the strict comparison, the post-loop condition and both totals before writing the strings.

Students type their answer here.

Apply the model independently

The remaining tasks change the context or reduce the support. Complete them without copying the worked model, then check that each explanation connects a mechanism to its consequence.

Written answer8 marks

Write procedural pseudocode or program code for count_matches(lines, target). It must examine each string in lines, count exact matches to target and return the count. Then give two tests, including an empty list or no-match case.

Use a parameterised subroutine, initial state, iteration, selection and return. Keep one coherent notation.

Students type their answer here.

Fill in the blanks4 marks
A procedural solution often uses named checkpoint gap 1 to organise operations. To understand behaviour, trace how checkpoint gap 2 changes. After an amendment, test a normal case and a checkpoint gap 3 case. A returned value is not necessarily checkpoint gap 4 unless a print/output operation uses it.

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 each consequence rather than only naming a feature.