Adding a condition column to a trace table

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

Adding a condition column to a trace table

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A trace table has a column headed 'score >= 50'. What goes in that column on each row?
A The value of score
B TRUE or FALSE
2. Which column heading is a good condition column?
A age >= 13
B age
3. score is 72 and the column heading is 'score >= 50'. What do you write?
A TRUE
B FALSE
4. temp is 15 and the column heading is 'temp > 20'. What do you write?
A TRUE
B FALSE
5. The condition column shows FALSE for 'lives = 0'. What does this tell you?
A The game is not over yet, so the IF part is skipped
B The IF part runs because the column has a value

Match the Pairs

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

Left columnRight column
1score >= 50 AColumns: x > 5 | y < 10 | x > 5 OR y < 10
2age >= 13 AND hasPermission = TRUE BA compound condition: check each part separately, then combine the results. It is TRUE only if both parts are TRUE.
3A condition column records TRUE or FALSE on every row, so you can see which path (THEN or ELSE) was taken and why. CThe column holds the value 72 instead of TRUE or FALSE. A condition column should be headed score >= 50 and record TRUE.
4To trace a compound condition, add one column for each part and then one for the whole condition. DIF temp > 30 THEN with a column headed: temp > 30
5Column heading: score | Row entry: 72 (under the IF score >= 50 test) Eage >= 13 is FALSE because 12 is less than 13. With AND, one FALSE part makes the whole condition FALSE, so the entry should be FALSE.
6Row: age = 12, column age >= 13 AND hasPermission = TRUE, entry TRUE (hasPermission is TRUE) FA condition column heading: write TRUE or FALSE on each row to show whether the score passed the test.

Definitions

condition column

Fill in the Blanks

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

1.
IF score > 50 THEN score | score _ 50 | OUTPUT
2.
IF age >= 13 THEN age = 12 | age >= 13 | _____
3.
IF age >= 13 AND age <= 17 THEN age | age >= 13 ___ age <= 17 | OUTPUT
4.
IF age >= 13 AND age <= 17 THEN 20 | age >= 13: TRUE | age <= 17: _____
5.
IF day = "Sat" OR day = "Sun" THEN Sat | TRUE | FALSE | ____

Spot the Error

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

Question 1
A age | age >= 13 | OUTPUT
B age | age + 13 | OUTPUT
C 13 | TRUE | Teen
D 15 | TRUE | Teen
Question 2
A score | score > 50 | OUTPUT
B 40 | FALSE | Try again
C 50 | FALSE | Try again
D 51 | FALSE | Pass
E 90 | TRUE | Pass
Question 3
A temp | TRUE | OUTPUT
B 35 | TRUE | Hot
C 25 | FALSE | Mild
D 30 | FALSE | Mild
Question 4
A age | age>=13 | age<=17 | AND
B 12 | FALSE | TRUE | FALSE
C 15 | TRUE | TRUE | TRUE
D 18 | TRUE | FALSE | TRUE
Question 5
A day | day=Sat | day=Sun | OR
B Fri | FALSE | FALSE | FALSE
C Sat | TRUE | FALSE | FALSE
D Sun | FALSE | TRUE | TRUE

Answer Key

Adding a condition column to a trace table
Section A: Quick Questions
Q1
B — TRUE or FALSE
Q2
A — age >= 13
Q3
A — TRUE
Q4
B — FALSE
Q5
A — The game is not over yet, so the IF part is skipped
Section B: Match the Pairs
Q1
score >= 50 → A condition column heading: write TRUE or FALSE on each row to show whether the score passed the test.
Q2
age >= 13 AND hasPermission = TRUE → A compound condition: check each part separately, then combine the results. It is TRUE only if both parts are TRUE.
Q3
A condition column records TRUE or FALSE on every row, so you can see which path (THEN or ELSE) was taken and why. → IF temp > 30 THEN with a column headed: temp > 30
Q4
To trace a compound condition, add one column for each part and then one for the whole condition. → Columns: x > 5 | y < 10 | x > 5 OR y < 10
Q5
Column heading: score | Row entry: 72 (under the IF score >= 50 test) → The column holds the value 72 instead of TRUE or FALSE. A condition column should be headed score >= 50 and record TRUE.
Q6
Row: age = 12, column age >= 13 AND hasPermission = TRUE, entry TRUE (hasPermission is TRUE) → age >= 13 is FALSE because 12 is less than 13. With AND, one FALSE part makes the whole condition FALSE, so the entry should be FALSE.
Section C: Definitions
Q1
condition column — A trace table column headed by a condition, such as age >= 13, that records TRUE or FALSE on each row so you can see which path the algorithm took and why.
Section D: Fill in the Blanks
Q1
IF score > 50 THEN score | score > 50 | OUTPUT
Q2
IF age >= 13 THEN age = 12 | age >= 13 | FALSE
Q3
IF age >= 13 AND age <= 17 THEN age | age >= 13 AND age <= 17 | OUTPUT
Q4
IF age >= 13 AND age <= 17 THEN 20 | age >= 13: TRUE | age <= 17: FALSE
Q5
IF day = "Sat" OR day = "Sun" THEN Sat | TRUE | FALSE | TRUE
Section E: Spot the Error
Q1
B — A condition column must be headed by a condition that can be TRUE or FALSE. 'age + 13' is a calculation, not a condition. The heading should be 'age >= 13'.
Q2
D — 51 > 50 is TRUE, so the condition column must show TRUE. This row also shows the output Pass, which only happens on the TRUE path.
Q3
A — TRUE is a value that goes in the rows, not the heading. The heading must be the condition itself, 'temp > 30', so you know what is being tested.
Q4
D — AND is only TRUE when both parts are TRUE. Here age<=17 is FALSE, so the AND column must be FALSE.
Q5
C — OR is TRUE when at least one part is TRUE. day=Sat is TRUE, so the OR column must be TRUE, not FALSE.