The OUTPUT column of a trace table

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

The OUTPUT column of a trace table

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A program runs OUTPUT Total, and Total holds 15. What goes in the OUTPUT column?
A Total
B 15
2. The program runs OUTPUT "Score: ", Score and Score holds 8. What goes in the OUTPUT column?
A Score: 8
B 8
3. Where do you write the result of an OUTPUT statement in a trace table?
A On the row where the OUTPUT statement runs
B On the last row of the table
4. FOR Count ← 1 TO 3 contains OUTPUT Count inside the loop. How is the OUTPUT column filled in?
A 1, then 2, then 3, each on its own row
B 1 2 3 all written on the final row
5. OUTPUT "Finished" comes after the end of a loop. How often is Finished written in the OUTPUT column?
A On every row of the loop
B Once, on the row after the loop ends

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1OUTPUT "Total: ", Total AWrites the text Total: followed by the current value of Total, together in the OUTPUT column on that row.
2FOR I ← 1 TO 3 OUTPUT I NEXT I BFOR I ← 1 TO 3 Total ← Total + I NEXT I OUTPUT Total
3Text in quotes is part of the output, so it is copied exactly into the OUTPUT column. CWrites 1, then 2, then 3 on three separate rows of the OUTPUT column.
4An OUTPUT placed after a loop is written once, on the row after the loop has finished. DOUTPUT "Pass"
5OUTPUT "Score" (Score is 8, but 8 is written in the OUTPUT column) EThe OUTPUT is inside the loop, so it happens on every repeat. Writing only the last value misses the first two outputs.
6FOR I ← 1 TO 3 OUTPUT I NEXT I (only 3 is written in the OUTPUT column) FThe word Score is in quotes, so it is text. The OUTPUT column should show Score, not the value 8.

Definitions

OUTPUT column

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Total ← 5 + 3 ______ Total
2.
Total ← 12 OUTPUT "Total: ", _____
3.
FOR Count ← 1 TO 3 OUTPUT _____ NEXT Count
4.
Total ← Total + Count NEXT Count ______ "Sum: ", Total
5.
Price ← 8 Tax ← Price ___ 2 OUTPUT "Tax: ", Tax

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A X ← 4
B OUTPUT "X is " X
C X ← X * 2
D OUTPUT "X is ", X
Question 2
A Name ← "Sam"
B OUTPUT Hello, Name
C OUTPUT "Bye"
Question 3
A OUTPUT Start
B Count ← 3
C OUTPUT Count
Question 4
A PRINT "Pass mark: ", 50
B Mark ← 62
C OUTPUT "Mark: ", Mark
Question 5
A FOR I ← 1 TO 3
B Sq ← I * I
C OUTPUT "Sq"
D NEXT I
E OUTPUT "Done"

Answer Key

The OUTPUT column of a trace table
Section A: Quick Questions
Q1
B — 15
Q2
A — Score: 8
Q3
A — On the row where the OUTPUT statement runs
Q4
A — 1, then 2, then 3, each on its own row
Q5
B — Once, on the row after the loop ends
Section B: Match the Pairs
Q1
OUTPUT "Total: ", Total → Writes the text Total: followed by the current value of Total, together in the OUTPUT column on that row.
Q2
FOR I ← 1 TO 3 OUTPUT I NEXT I → Writes 1, then 2, then 3 on three separate rows of the OUTPUT column.
Q3
Text in quotes is part of the output, so it is copied exactly into the OUTPUT column. → OUTPUT "Pass"
Q4
An OUTPUT placed after a loop is written once, on the row after the loop has finished. → FOR I ← 1 TO 3 Total ← Total + I NEXT I OUTPUT Total
Q5
OUTPUT "Score" (Score is 8, but 8 is written in the OUTPUT column) → The word Score is in quotes, so it is text. The OUTPUT column should show Score, not the value 8.
Q6
FOR I ← 1 TO 3 OUTPUT I NEXT I (only 3 is written in the OUTPUT column) → The OUTPUT is inside the loop, so it happens on every repeat. Writing only the last value misses the first two outputs.
Section C: Definitions
Q1
OUTPUT column — The trace table column where you write each value or message shown by an OUTPUT statement, on the row where it happens. Text in quotes is copied exactly as the output.
Section D: Fill in the Blanks
Q1
Total ← 5 + 3 OUTPUT Total
Q2
Total ← 12 OUTPUT "Total: ", Total
Q3
FOR Count ← 1 TO 3 OUTPUT Count NEXT Count
Q4
Total ← Total + Count NEXT Count OUTPUT "Sum: ", Total
Q5
Price ← 8 Tax ← Price DIV 2 OUTPUT "Tax: ", Tax
Section E: Spot the Error
Q1
B — The text and the variable must be separated by a comma. It should be OUTPUT "X is ", X so the OUTPUT column shows X is 4 on that row.
Q2
B — Text to be shown exactly must be in quotes. Without quotes, Hello would be treated as a variable. It should be OUTPUT "Hello ", Name, giving Hello Sam in the OUTPUT column.
Q3
A — Start has no quotes, so it is treated as a variable that does not exist. It should be OUTPUT "Start" so the word Start is written in the OUTPUT column.
Q4
A — Cambridge pseudocode uses OUTPUT, not PRINT. Only an OUTPUT statement puts a value in the OUTPUT column, so the line should be OUTPUT "Pass mark: ", 50.
Q5
C — Quotes make Sq literal text, so the OUTPUT column would show Sq every time. It should be OUTPUT Sq to show the values 1, 4 and 9, one on each loop row.