Tracing a flowchart with test values

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

Tracing a flowchart with test values

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Where do you begin when tracing a flowchart with test values?
A At the first decision diamond
B At the Start oval
2. A diamond asks: Is mark >= 50? The test value is mark = 42. Which arrow do you follow?
A The Yes arrow
B The No arrow
3. What should you do each time you reach a decision diamond?
A Answer it using the current values and record the Yes or No in the trace table
B Pick the arrow that leads to Stop the fastest
4. A loop arrow goes back up to an earlier diamond. What do you do when you follow it?
A Ask the diamond's question again using the updated values and add a new row
B Skip the diamond and carry on to Stop
5. A flowchart has the test value count = 3. A process box says count ← count + 1. What does the trace table show for count afterwards?
A 4
B 3

Match the Pairs

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

Left columnRight column
1Start oval AA loop arrow must be followed back to the earlier box. Keep tracing, adding rows, until the diamond sends you to Stop
2Diamond: age >= 16? Bcount <- count + 1 (arrow returns to: count < 3?)
3A loop arrow goes back to an earlier box, so you keep tracing and add a new trace table row each time round CA decision. Check the current value of age, then follow the Yes or No arrow and record the answer
4The trace finishes when you follow the arrows to the Stop oval, and the last row holds the final values DStop oval (last row: total = 12)
5Test value mark = 45. Diamond: mark >= 50? Trace table records Yes and follows the Yes arrow EThe place where you begin tracing, before writing the test values in the trace table
6Loop arrow reached: student jumps straight to Stop and writes no new trace table row FThe diamond was answered wrongly. 45 is not >= 50, so the answer is No and you must follow the No arrow

Definitions

trace a flowchart

Fill in the Blanks

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

1.
__ mark >= 50: print("Pass") else:
2.
if mark >= 50: print("Pass") ____:
3.
count = 0 _____ count < 3: count = count + 1
4.
count = 0 while count < 3: count = _____ + 1
5.
x = 5 if x > 3: _____("Yes")

Spot the Error

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

Question 1
A Start
B age = 15
C age >= 16? Yes -> Can drive
D Stop
Question 2
A Start at the diamond
B mark = 45
C mark >= 50? No
D Follow No arrow to Fail
E Stop
Question 3
A Start: n = 1
B n < 3? Yes, n = n + 1 -> 2
C n < 3? Yes, n = n + 1 -> 3
D n < 3? Yes -> Stop
Question 4
A Start
B x = 8, y = 3
C x > y? No -> print x
D Stop
Question 5
A Leave the table empty at first
B Follow arrow from Start
C Record each diamond's answer
D Stop when you reach Stop

Answer Key

Tracing a flowchart with test values
Section A: Quick Questions
Q1
B — At the Start oval
Q2
B — The No arrow
Q3
A — Answer it using the current values and record the Yes or No in the trace table
Q4
A — Ask the diamond's question again using the updated values and add a new row
Q5
A — 4
Section B: Match the Pairs
Q1
Start oval → The place where you begin tracing, before writing the test values in the trace table
Q2
Diamond: age >= 16? → A decision. Check the current value of age, then follow the Yes or No arrow and record the answer
Q3
A loop arrow goes back to an earlier box, so you keep tracing and add a new trace table row each time round → count <- count + 1 (arrow returns to: count < 3?)
Q4
The trace finishes when you follow the arrows to the Stop oval, and the last row holds the final values → Stop oval (last row: total = 12)
Q5
Test value mark = 45. Diamond: mark >= 50? Trace table records Yes and follows the Yes arrow → The diamond was answered wrongly. 45 is not >= 50, so the answer is No and you must follow the No arrow
Q6
Loop arrow reached: student jumps straight to Stop and writes no new trace table row → A loop arrow must be followed back to the earlier box. Keep tracing, adding rows, until the diamond sends you to Stop
Section C: Definitions
Q1
trace a flowchart — Follow a flowchart from Start to Stop using test values, noting each diamond's Yes or No answer in a trace table and following loop arrows back until Stop.
Section D: Fill in the Blanks
Q1
if mark >= 50: print("Pass") else:
Q2
if mark >= 50: print("Pass") else:
Q3
count = 0 while count < 3: count = count + 1
Q4
count = 0 while count < 3: count = count + 1
Q5
x = 5 if x > 3: print("Yes")
Section E: Spot the Error
Q1
C — The test value is 15, and 15 >= 16 is false, so the answer is No. Follow the No arrow to 'Too young'. The line should be: age >= 16? No -> Too young.
Q2
A — A trace begins at the Start oval. A diamond is a decision, which you reach later. The line should be: Start at the oval.
Q3
D — When n is 3, n < 3 is false, so the answer is No, not Yes. The No arrow leads out of the loop to Stop. The line should be: n < 3? No -> Stop.
Q4
C — With x = 8 and y = 3, x > y is true, so the answer is Yes. The line should be: x > y? Yes -> print x.
Q5
A — The first job is to write the test values in the trace table. Without them you cannot answer the decisions. The line should be: Write test values in the table.