All subjects · Computer Science · WCP04 Advanced Practical Programming and Problem-solving
Computational thinking, IDEs and debugging tools
Edexcel IAL Computer Science · WCP04 Advanced Practical Programming and Problem-solving
Unit 4 is a practical exam on a computer, so how you think about a problem and how well you use your development tools matter as much as knowing syntax.
Computational thinking
- Decomposition: break the problem into smaller parts that can each be solved and tested, such as 'load data', 'calculate scores', 'display leaderboard'.
- Abstraction: remove detail that does not matter, keeping only what the solution needs (a diving score needs judges' marks, not the judges' names).
- Pattern recognition: spot repeated steps and turn them into loops or reusable subprograms.
- Algorithmic thinking: write the exact sequence of steps, including what happens at the edges (empty list, one item, tied scores).
Tracing
A trace table records each variable's value after every step. It is the quickest way to predict output and to find logic errors without running code.
n = 6
result = 1
while n > 1:
result = result * n
n = n - 2
print(result)| n | result | n > 1? |
|---|---|---|
| 6 | 1 | True |
| 4 | 6 | True |
| 2 | 24 | True |
| 0 | 48 | False |
Trace of the loop: it prints 48.
Using an IDE
The exam lets you use the Python 3 IDE of your choice, with AI code generation disabled. Know these features well:
- Syntax highlighting and auto-indentation show mistyped keywords and misplaced blocks.
- Error messages (tracebacks): read the last line first; it names the exception type and message. The lines above show the line numbers that led to it.
- Debugger: a breakpoint pauses the program at a line; step over runs the next line; step into follows a function call; a watch or variables pane shows values as they change.
- Run often: write a few lines, run, check, continue.
Other tools
- print() statements showing variable values at key points are a quick debugging aid; remove them before submitting.
- assert checks that something you believe is true really is: assert len(scores) == 5.
- A linter or the IDE's warnings flag unused variables and undefined names before you run.
Worked example
A function should return the largest item in a list, but max_item([-4, -2, -9]) returns 0. Find the bug using a trace.
- ```python def max_item(items): biggest = 0 for x in items: if x > biggest: biggest = x return biggest print(max_item([-4, -2, -9])) ```
- Trace: biggest starts at 0. -4 > 0? No. -2 > 0? No. -9 > 0? No. It returns 0.
- Fix: start from the first item, biggest = items[0], so negative lists work. After the fix the call prints -2.
Answer: A logic error: the initial value 0 is not a safe starting point. Initialise from the data.
Check yourself
- What does this program print?
```python
n = 6
result = 1
while n > 1:
result = result * n
n = n - 2
print(result)
```
Show answer
48. Trace: result becomes 6, then 24, then 48 as n goes 6, 4, 2; then n = 0 stops the loop. Output: `48`
- What does this program print?
```python
x = 3
y = 0
for i in range(4):
y = y + x * i
x = x - 1
print(y)
```
Show answer
4. i = 0: y = 0, x = 2. i = 1: y = 2, x = 1. i = 2: y = 4, x = 0. i = 3: y = 4, x = -1. Output: `4`
- What does setting a breakpoint on line 12 and running in debug mode do?
- Deletes line 12
- Pauses the program just before line 12 runs so you can inspect variables
- Stops the program permanently at line 12 and discards its variables
- Skips line 12 every time
Show answer
Pauses the program just before line 12 runs so you can inspect variables. A breakpoint pauses execution there; you can then inspect values and step through the following lines.
- Where should you look first in a Python traceback?
- The first line, which gives the file name
- The middle line, which gives the function name
- The last line, which gives the exception type and message
- The line with the most characters
Show answer
The last line, which gives the exception type and message. The final line states what went wrong (for example NameError: name 'totl' is not defined). The lines above show how the program got there.
- A diving competition program stores each dive's judges' scores and difficulty but not the colour of the divers' costumes. Which technique is this?
- Abstraction
- Decomposition
- Pattern recognition
- Encapsulation
Show answer
Abstraction. Leaving out detail irrelevant to the problem is abstraction.
- Splitting a leaderboard program into load_results(), calculate_totals() and display_table() is an example of what?
- Abstraction
- Recursion
- Decomposition
- Polymorphism
Show answer
Decomposition. Breaking a problem into smaller sub-problems, each its own subprogram, is decomposition.
- In a debugger, what is the difference between 'step into' and 'step over' on a line that calls a function?
- Step into enters the function and pauses at its first line; step over runs the whole call and pauses at the next line
- Step over enters the function; step into skips it
- Step over restarts the program from the first line
- Step into deletes the function call
Show answer
Step into enters the function and pauses at its first line; step over runs the whole call and pauses at the next line. Step into follows execution inside the called function; step over treats the call as a single step.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Computer Science specification, Issue 1 (March 2026)
- Pearson Edexcel IAL Computer Science Unit 4 Programming Language Subset (PLS)
- Pearson Edexcel IAL Computer Science sample assessment materials (Unit 3 and Unit 4)
Last updated 8 November 2026. Spotted a mistake? Tell us.