Skip to content
Menu

Year 10 (ages 14–15, Grade 9 in the US) · Computing · GCSE programming · Lesson 20

Exam-style programming task: plan, write, test

Bringing it all together on an exam-style task: reading the requirements, decomposing the problem, planning with pseudocode, writing a Python program with input, validation, a loop, a list and a function, and testing it with a test plan.

Exam boards: this lesson matches the Pearson Edexcel GCSE computing courses. Check which course your school follows.

Whiteboard video lesson: Exam-style programming task: plan, write, test

8-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Analyse a programming task
  • Plan a solution
  • Write a complete Python program
  • Test and refine the program

The method

  1. Read the task twice; underline every requirement.
  2. Decompose: inputs, processes, outputs.
  3. Write and test one part at a time.
  4. Test with normal, boundary and erroneous data; tick off requirements.

Key words: requirements, decomposition, validation, testing, refinement.

Worked examples

Worked examples from the lesson, with every step.

Question 1

Write the validation for the number of students (1–30).

  1. Step 1: c:n = int(input("Students (1-30): "))
  2. Step 2: c:while n < 1 or n > 30: n = int(input("Again: "))

Answer: input, then while n < 1 or n > 30: ask again

Question 2

Write the loop that reads n marks into a list.

  1. Step 1: c:marks = []
  2. Step 2: c:for i in range(n): marks.append(int(input("Mark: ")))

Answer: for loop n times, appending each mark

Question 3

With marks [40, 60, 80], what should the program output?

  1. Step 1: average 60; highest 80
  2. Step 2: 60 and 80 → 2

Answer: average 60, highest 80, 2 passed