Download presentation
Presentation is loading. Please wait.
1
Trace Tables In today’s lesson we will look at:
what we mean by a “dry run” the purpose of a “trace table” an example of how to use a trace table to test a program
2
Dry Run When you create a program, it’s easy to miss something out, or, when counting, to go too far or stop too soon. Testing with sample data helps to identify such problems. Sometimes programmers will test their program without actually running them – they will look at their code and work out the values of the variable on each line, or for each repetition of a loop. Testing in this way is known as a dry run. The dry run can be based on a flowchart, pseudocode, or the actual code in your chosen programming language.
3
Trace Table One of the most common way to record the results of a dry run is in a trace table. A trace table has a column for each of your variables, and sometimes an additional column for OUTPUT, depending on the purpose of the program. There will be a row for each line, or iteration, of the code that you want to test – e.g. if a loop repeats ten times, there will be ten rows in the table. The programmer works out (manually) what the values of the variables should be at each stage and puts the values in the table. Remember that variables can be strings, Boolean, etc., so the value won’t always be a number.
4
Example Here is a sample program:
Here is what the trace table would look like: y = 3 for x = 1 to 4 y = y + x next print y y = 3 for x in range(1,5) y = y + x print(y) X Y OUTPUT 1 3 2 4 3 6 4 9 4 13 13
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.