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.

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Computational thinking

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)
nresultn > 1?
61True
46True
224True
048False

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:

Other tools

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.

  1. ```python def max_item(items): biggest = 0 for x in items: if x > biggest: biggest = x return biggest print(max_item([-4, -2, -9])) ```
  2. Trace: biggest starts at 0. -4 > 0? No. -2 > 0? No. -9 > 0? No. It returns 0.
  3. 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.

Key idea: Decompose, abstract, spot patterns, write exact steps. Trace tables predict output. Read tracebacks from the last line up; use breakpoints, stepping and watches.

Check yourself

  1. 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`

  2. 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`

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.