Error: = used instead of ←

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

Error: = used instead of ←

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly stores the value 0 in the variable Total?
A Total = 0
B Total ← 0
2. Which condition correctly checks whether Score is equal to 5?
A IF Score = 5 THEN
B IF Score ← 5 THEN
3. A student writes Count = 0 at the start of an algorithm to set a counter. What is the error?
A = compares, so they should have used Count ← 0 to assign
B ← compares, so they should have used Count = 0 to assign
4. Which line is correct for storing the result of an addition?
A Total ← Total + Mark
B Total = Total + Mark
5. Which statement about the symbols is true?
A = stores a value and ← compares two values
B ← stores a value and = compares two values

Match the Pairs

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

Left columnRight column
1Total = 0 AIF Score = 5 THEN
2Total ← 0 BWrong: = compares, so this does not store 0 in Total. It should be Total ← 0.
3Use ← to store a value in a variable C= is used to assign, but = only compares. The fix is Count ← Count + 1.
4Use = to compare a variable with a value in a condition DCorrect: stores the value 0 in the variable Total.
5Count = Count + 1 E← is used to compare, but ← only assigns. The fix is IF Score = 5 THEN.
6IF Score ← 5 THEN FScore ← 5

Definitions

Total ← 0

Fill in the Blanks

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

1.
Total _ 0
2.
IF Score _ 5 THEN OUTPUT "Full marks" ENDIF
3.
Price ← 10 Total _ Price * 2 OUTPUT Total
4.
DECLARE Total : INTEGER Total _ 0 OUTPUT Total
5.
IF Answer _ "Y" THEN Score ← Score + 1 ENDIF

Spot the Error

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

Question 1
A DECLARE Total : INTEGER
B Total = 0
C OUTPUT Total
Question 2
A DECLARE Score : INTEGER
B INPUT Score
C IF Score ← 5
D THEN
E OUTPUT "Full marks"
F ENDIF
Question 3
A DECLARE Count : INTEGER
B Count ← 0
C Count = Count + 1
D OUTPUT Count
Question 4
A DECLARE Price : REAL
B Price = 4.5
C OUTPUT Price
Question 5
A Total ← 0
B FOR Count ← 1 TO 5
C INPUT Mark
D Total = Total + Mark
E NEXT Count

Answer Key

Error: = used instead of ←
Section A: Quick Questions
Q1
B — Total ← 0
Q2
A — IF Score = 5 THEN
Q3
A — = compares, so they should have used Count ← 0 to assign
Q4
A — Total ← Total + Mark
Q5
B — ← stores a value and = compares two values
Section B: Match the Pairs
Q1
Total = 0 → Wrong: = compares, so this does not store 0 in Total. It should be Total ← 0.
Q2
Total ← 0 → Correct: stores the value 0 in the variable Total.
Q3
Use ← to store a value in a variable → Score ← 5
Q4
Use = to compare a variable with a value in a condition → IF Score = 5 THEN
Q5
Count = Count + 1 → = is used to assign, but = only compares. The fix is Count ← Count + 1.
Q6
IF Score ← 5 THEN → ← is used to compare, but ← only assigns. The fix is IF Score = 5 THEN.
Section C: Definitions
Q1
Total ← 0 — Use ← to store a value, so write Total ← 0, not Total = 0. Use = only to compare, as in IF Score = 5, not IF Score ← 5. Swapping them is an error.
Section D: Fill in the Blanks
Q1
Total ← 0
Q2
IF Score = 5 THEN OUTPUT "Full marks" ENDIF
Q3
Price ← 10 Total ← Price * 2 OUTPUT Total
Q4
DECLARE Total : INTEGER Total ← 0 OUTPUT Total
Q5
IF Answer = "Y" THEN Score ← Score + 1 ENDIF
Section E: Spot the Error
Q1
B — = compares values, it does not store them. To store 0 in Total, use the assignment arrow: Total ← 0.
Q2
C — An IF condition compares values, so it needs =. ← is for assignment. The line should be IF Score = 5.
Q3
C — This line should store a new value in Count, so it needs ←, not =. Write Count ← Count + 1.
Q4
B — = compares and does not store a value. Use the assignment arrow to give Price its value: Price ← 4.5.
Q5
D — Adding Mark to the running total must be stored in Total, so it needs ←. Write Total ← Total + Mark.