Pseudocode assignment: ←

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

Pseudocode assignment: ←

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly sets the variable Total to 0 in Cambridge pseudocode?
A 0 ← Total
B Total ← 0
2. In Total ← 0, which side of the ← symbol holds the variable that receives the value?
A The left side
B The right side
3. What does Total ← Total + Score do?
A Adds Score to the current value of Total and stores the result in Total
B Checks whether Total is equal to Total + Score
4. Total is 10 and Score is 5. What is Total after Total ← Total + Score?
A 15
B 5
5. Which of these is an assignment that stores the value 7 in Score?
A Score → 7
B Score ← 7

Match the Pairs

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

Left columnRight column
1Total ← 0 AStores the value 0 in the variable Total, so Total starts at zero
2Total ← Total + Score BCount ← 10
3The variable that receives the value goes on the left of the ← symbol CThe calculation is on the left. The variable must be on the left and the calculation on the right, so it should be Total ← Total + Score.
4To keep a running total, assign the old total plus the new value back to the total DTotal ← Total + Score
50 ← Total EThe value and variable are the wrong way round. The variable must be on the left and the value on the right, so it should be Total ← 0.
6Total + Score ← Total FWorks out the current Total plus Score, then stores the answer back in Total

Definitions

Total ← 0

Fill in the Blanks

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

1.
Total _ 0
2.
Total ← 0 Score ← 8 _____ ← Total + Score
3.
Total ← 0 Score ← 8 Total ← Total _ Score
4.
Total ← _ OUTPUT Total
5.
Score ← 8 Total ← _____ + Score

Spot the Error

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

Question 1
A INPUT Score
B 0 ← Total
C Total ← Total + Score
D OUTPUT Total
Question 2
A Total ← 0
B Total + 5 ← Total
C OUTPUT Total
Question 3
A Total ← 0
B INPUT Score
C Total ← Score
D OUTPUT Total
Question 4
A Count ← 0
B INPUT Mark
C IF Mark >= 50 THEN
D Count ← Count - 1
E ENDIF
Question 5
A INPUT Price
B INPUT Qty
C Cost Price * Qty
D OUTPUT Cost

Answer Key

Pseudocode assignment: ←
Section A: Quick Questions
Q1
B — Total ← 0
Q2
A — The left side
Q3
A — Adds Score to the current value of Total and stores the result in Total
Q4
A — 15
Q5
B — Score ← 7
Section B: Match the Pairs
Q1
Total ← 0 → Stores the value 0 in the variable Total, so Total starts at zero
Q2
Total ← Total + Score → Works out the current Total plus Score, then stores the answer back in Total
Q3
The variable that receives the value goes on the left of the ← symbol → Count ← 10
Q4
To keep a running total, assign the old total plus the new value back to the total → Total ← Total + Score
Q5
0 ← Total → The value and variable are the wrong way round. The variable must be on the left and the value on the right, so it should be Total ← 0.
Q6
Total + Score ← Total → The calculation is on the left. The variable must be on the left and the calculation on the right, so it should be Total ← Total + Score.
Section C: Definitions
Q1
Total ← 0 — The ← symbol is assignment: it stores the value on its right in the variable on its left. Total ← 0 sets Total to 0. Total ← Total + Score adds Score to Total.
Section D: Fill in the Blanks
Q1
Total ← 0
Q2
Total ← 0 Score ← 8 Total ← Total + Score
Q3
Total ← 0 Score ← 8 Total ← Total + Score
Q4
Total ← 0 OUTPUT Total
Q5
Score ← 8 Total ← Total + Score
Section E: Spot the Error
Q1
B — The variable must be on the left of ← and the value on the right. 0 is not a variable, so it cannot store anything. It should be Total ← 0.
Q2
B — The left side of ← must be a single variable. Total + 5 is a calculation, so it goes on the right. It should be Total ← Total + 5.
Q3
C — This replaces Total with Score instead of adding Score to the running total. It should be Total ← Total + Score.
Q4
D — Counting passes needs Count to go up by 1, but this subtracts 1. The line should be Count ← Count + 1.
Q5
C — The assignment arrow is missing, so nothing is stored in Cost. It should be Cost ← Price * Qty.