A trace table is a table that follows a program by hand: one column for each variable, one row for each line run, holding the values of the variables after that line.
Contoh
Example 15.6 (Tracing five lines)
A dash means that the variable has no value yet.
| line | instruction | a | b |
|---|---|---|---|
| 1 | a = 5 | 5 | – |
| 2 | b = a + 3 | 5 | 8 |
| 3 | a = b * 2 | 16 | 8 |
| 4 | b = b - a | 16 | |
| 5 | print(a, b) | 16 |
The program should print 16 -8. Running it confirms the table: