Predict · Trace · Explain
Trace Table Lab
Follow a program one statement at a time. Track what changes, what stays the same and what appears on screen.
Start here
- Read the code and predict its output.
- Complete the short practice table before checking.
- Use Next step to compare your reasoning with the worked trace.
Choose a program
Read the code
1. Predict the output
Need a hint?
2. Complete the missing values
Each row records values after the named line executes. Line numbers match your chosen code view. Unassigned variables are shown as “not set”.
3. Reveal the worked trace
Current code
Output revealed so far
No output yet.
The highlighted line is the last executed line. Its values appear in the final revealed trace row.
A for-loop header appears when it assigns a new loop value. If and while tests have their own True/False rows. This is a teaching trace, not a count of processor instructions. In the Python model the for-loop variable retains its last assigned value.
CSV files can be opened in a spreadsheet and copied into OneNote. Downloading answers reveals the complete worked trace.
OneNote activity
Record your prediction, one corrected trace row and an explanation of the change. For debugging tasks, state the requirement, the fault, the correction and a test with its expected result.
Scope and conventions
These seven curated programs model selected GCSE 1.4.1 and Unit 2 programming/testing skills. The pseudocode follows WJEC Appendix B where defined. Array literal notation is labelled separately. A trace table is a way to reason about code, not an official assessment template.
The lab does not run arbitrary Python. The faulty loop stops after 40 model steps. A step limit alone does not prove that an arbitrary program would never finish. AS students can use these as foundation practice; subroutines, recursion and larger algorithms need further work.