Pseudocode for presenting results

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

Pseudocode for presenting results

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which print statement gives the user a clearer, labelled result?
A print total
B print "Total: " + total
2. A report lists 30 students. How should each student appear in the output?
A All records joined together on one long line
B One record per line, printed inside a loop
3. Where should the heading of a report be printed?
A Before the loop, so it prints once
B Inside the loop, so it prints for every record
4. Which pseudocode prints the grand total correctly after a report loop?
A for i from 1 to 5 print names[i] next i print "Total: " + total
B print "Total: " + total for i from 1 to 5 print names[i] next i
5. Which line prints a labelled value on the same line?
A print "Mark: " + mark
B print "Mark: " mark

Match the Pairs

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

Left columnRight column
1print "Total: " + total AThe heading is printed inside the loop, so it repeats before every record instead of appearing once
2print "=== Class Report ===" Bfor i from 1 to 5 total <- total + marks[i] next i print "Total: " + total
3Print one record per line by putting the print statement inside a loop CThe + joining the label and the variable is missing, so the label and value are not combined into one output
4Print the total once after the loop, so it appears at the end of the report Dfor i from 1 to 5 print names[i] + ": " + marks[i] next i
5print "Total: " total EPrints a heading line at the top of a report
6for i from 1 to 5 print "Report" print names[i] + ": " + marks[i] next i FShows a label followed by the value of total, so the result is easy to read

Definitions

print "Total: " + total

Fill in the Blanks

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

1.
_____ "Total: " + total
2.
print "Total: " _ total
3.
for i from 1 to 5 print "Mark: " + marks[_] end for
4.
average <- total / count print "Student Report" print "Average: " + _______
5.
___ i from 1 to count print names[i] + ": " + marks[i] end for

Spot the Error

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

Question 1
A print "Student Report"
B print "Name: " name
C print "Mark: " + mark
Question 2
A show "=== Sales Report ==="
B total <- 0
C print "Total: " + total
Question 3
A for i from 1 to 3
B print "Pet " + i
C print pet[i] + ": " + age[1]
D end for
Question 4
A total <- 0
B for i from 1 to 3
C total <- mark[i]
D end for
E print "Total: " + total
Question 5
A print "Pet Ages"
B for i from 1 3
C print pet[i] + ": " + age[i]
D end for

Answer Key

Pseudocode for presenting results
Section A: Quick Questions
Q1
B — print "Total: " + total
Q2
B — One record per line, printed inside a loop
Q3
A — Before the loop, so it prints once
Q4
A — for i from 1 to 5 print names[i] next i print "Total: " + total
Q5
A — print "Mark: " + mark
Section B: Match the Pairs
Q1
print "Total: " + total → Shows a label followed by the value of total, so the result is easy to read
Q2
print "=== Class Report ===" → Prints a heading line at the top of a report
Q3
Print one record per line by putting the print statement inside a loop → for i from 1 to 5 print names[i] + ": " + marks[i] next i
Q4
Print the total once after the loop, so it appears at the end of the report → for i from 1 to 5 total <- total + marks[i] next i print "Total: " + total
Q5
print "Total: " total → The + joining the label and the variable is missing, so the label and value are not combined into one output
Q6
for i from 1 to 5 print "Report" print names[i] + ": " + marks[i] next i → The heading is printed inside the loop, so it repeats before every record instead of appearing once
Section C: Definitions
Q1
print "Total: " + total — A print statement that joins a label to a value so results are readable. Use headings, labels and one record per line, often inside a loop, to build a report.
Section D: Fill in the Blanks
Q1
print "Total: " + total
Q2
print "Total: " + total
Q3
for i from 1 to 5 print "Mark: " + marks[i] end for
Q4
average <- total / count print "Student Report" print "Average: " + average
Q5
for i from 1 to count print names[i] + ": " + marks[i] end for
Section E: Spot the Error
Q1
B — The label and the variable are not joined. A + is needed between them: print "Name: " + name.
Q2
A — Pseudocode uses the print keyword to display a heading. It should be print "=== Sales Report ===".
Q3
C — The age index is fixed at 1, so every line would show the first age. It should use the loop counter: age[i].
Q4
C — This overwrites total each time round the loop instead of adding to it. It should be total <- total + mark[i], so the final total is correct.
Q5
B — The loop header is missing the keyword to. It should be for i from 1 to 3, so one record is printed per pass.