Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Variables and Constants

Tracing variables

All topicsPractise exam questions
Knowledge organiser

Variables and Constants

301.3c

Track value changes in code.

What you need to know

Tracing means following code line by line and recording the value of each variable after each statement. This is often done with a trace table.

Key points

  • Write each variable as a column
  • Step through each line and update values
  • A trace table shows the value after each line executes
  • Helps find logic errors by hand

Code examples

Trace this code
python
x = 3
y = x + 2
x = y * 2
# Trace: x=3 → y=5 → x=10