Community resourceWorksheet
1CP2-CT-7.1 Programming constructs reactivation
Part 1 of 5 · 1CP2-CT-7 · Subprograms, scope and libraries
The later-course reactivation worksheet, joining sequence, selection and iteration back into one working program.
Students will:
- read a program by the state it changes rather than by its keywords
- predict the exact output of an accumulator and counter loop
- choose between a for loop and a while loop from the problem
- identify why a while loop fails to terminate and correct it
- construct an integrated program that totals and counts in one pass
Inside: 6 explanation cells, 3 multiple-choice questions, 1 Python task, 1 trace table, 1 fill-in-the-blanks cell and 2 written answers. 15 marks, about 45 minutes.
Series: 1CP2-CT-7 · Subprograms, scope and libraries, part 1 of 5.
Shared by Coding PathwayVerified teacher
- 14 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Programming constructs reactivation
This later-course reactivation joins familiar constructs into one program. Sequence fixes order, selection chooses a path, and iteration repeats. A one-dimensional structure stores an ordered set of items. The examination expects you to read, trace, debug and construct programs—not merely name the constructs.
1. Model a complete data-processing pattern
scores = [12, 8, 15, 6]
total = 0
high_count = 0
for score in scores:
total = total + score
if score >= 10:
high_count = high_count + 1
print(total)
print(high_count)
The loop visits each list item once. The accumulator total changes every pass. high_count changes only when selection is true. Reading by state change is more reliable than guessing from the final print lines.
if statement performs gap 2. The for loop performs gap 3 through a one-dimensional structure.- iteration
- selection
- sequence
- validation
2. Predict before execution
Read this code without running it.
values = [3, 7, 2]
total = 0
for value in values:
if value > 3:
total = total + value
else:
total = total + 1
print(total)
What exact value is printed?
- A8
- B9
- C12
- D13
Explain how the program reaches the printed value.
Describe all three iterations and the branch used.
Students type their answer here.
Complete the trace table for this count-and-total algorithm.
Record changes to item, total and passes on every iteration.
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.
items = [4, 1, 6]total = 0passes = 0for item in items:total = total + itempasses = passes + 1print(total)print(passes)
| Row | items | total | passes | item | Output |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | |||||
| 7 |
3. Choose the loop that matches the problem
Use a for loop when traversing every item in a known structure or a known range. Use a while loop when repetition depends on a condition, such as asking again while input remains invalid. The condition must be able to become false; otherwise the loop may never terminate.
A program must keep asking until a PIN has exactly four digits. Which construct best controls the repetition?
- AA single `if`
- BA `while` loop
- CA list assignment
- DAn `elif` with no `if`
A loop contains while attempts < 3: but never changes attempts. Identify the likely error and describe the correction.
Connect the unchanged control variable to termination.
Students type their answer here.
4. Construct an integrated solution
Complete a program that visits every value in temperatures. It must total all values and count values at least 20. Store the count in warm_count, store the total in total, and print both values on separate lines.
temperatures = [18, 22, 20, 16, 25]
# Total the values and count values at least 20.
Which claim about iterating for item in items is correct?
- AIt changes every list item automatically.
- BIt visits each item in order without needing an index variable.
- CIt can run only when the list contains strings.
- DIt always repeats forever.
Route forward
You have reactivated sequence, selection, repetition and one-dimensional traversal. Next you will organise these constructs inside parameterised subprograms and control the scope of names.