Comparison blocks: >, < and =

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

Comparison blocks: >, < and =

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does a comparison block like score > 10 report?
A true or false
B A number
2. The score variable is 15. Which block is true?
A score > 10
B score < 10
3. Which symbol means 'less than'?
A >
B <
4. The lives variable is 3. What does lives = 3 report?
A false
B true
5. The score variable is 4. What does score > 10 report?
A false
B true

Match the Pairs

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

Left columnRight column
1score > 10 AReports true when the lives variable is less than 3, otherwise false
2lives < 3 Btimer > 30
3An equals block is true only when both values are exactly the same Canswer = 7
4Comparing a variable to a number to see if it is bigger than the number DUsing < 0 means less than 0, which is never true for lives that stop at 0. Use lives = 0 to check for no lives.
5if score > 10 then say 'Win' (checking for exactly 10 using >) EUsing > when you want to check for exactly 10. The > block is false when the score is 10. Use = instead.
6lives < 0 (to check the player has no lives left) FReports true when the score variable is greater than 10, otherwise false

Definitions

score > 10

Fill in the Blanks

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

1.
if <score _ 10> then
2.
if <lives _ 3> then say (Careful!) for 2 seconds
3.
if <answer _ 7> then say (Correct!) for 2 seconds
4.
set score to 12 if <_____ > 10> then say (You win!) for 2 seconds
5.
set score to 8 <score < 10> reports ____

Spot the Error

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

Question 1
A when green flag clicked
B set score to 12
C if score < 10 then
D say Your score is over 10!
E end
Question 2
A set lives to 0
B if lives == 0 then
C say Game over
D end
Question 3
A if age > 10 then
B say You are under 10
C else
D say You are 10 or older
E end
Question 4
A if score > then
B say Top score!
C end
Question 5
A set coins to 7
B if coins is 7 then
C say I have 7 coins
D end

Answer Key

Comparison blocks: >, < and =
Section A: Quick Questions
Q1
A — true or false
Q2
A — score > 10
Q3
B — <
Q4
B — true
Q5
A — false
Section B: Match the Pairs
Q1
score > 10 → Reports true when the score variable is greater than 10, otherwise false
Q2
lives < 3 → Reports true when the lives variable is less than 3, otherwise false
Q3
An equals block is true only when both values are exactly the same → answer = 7
Q4
Comparing a variable to a number to see if it is bigger than the number → timer > 30
Q5
if score > 10 then say 'Win' (checking for exactly 10 using >) → Using > when you want to check for exactly 10. The > block is false when the score is 10. Use = instead.
Q6
lives < 0 (to check the player has no lives left) → Using < 0 means less than 0, which is never true for lives that stop at 0. Use lives = 0 to check for no lives.
Section C: Definitions
Q1
score > 10 — A comparison block checks two values and reports true or false. This one is true when the score variable is greater than 10. Use < for less than and = for equal to.
Section D: Fill in the Blanks
Q1
if <score > 10> then
Q2
if <lives < 3> then say (Careful!) for 2 seconds
Q3
if <answer = 7> then say (Correct!) for 2 seconds
Q4
set score to 12 if <score > 10> then say (You win!) for 2 seconds
Q5
set score to 8 <score < 10> reports true
Section E: Spot the Error
Q1
C — The program says the score is over 10, so it needs 'greater than' (>). With < the block checks for less than 10, which is false when the score is 12. It should be: if score > 10 then.
Q2
B — The equals comparison block uses a single = sign, not two. It should be: if lives = 0 then.
Q3
A — The message says the person is under 10, so the block must use 'less than' (<). It should be: if age < 10 then.
Q4
A — A comparison block needs two values, one on each side of the symbol. The number 10 is missing. It should be: if score > 10 then.
Q5
B — There is no 'is' comparison block. To check if two values are equal, use the = block. It should be: if coins = 7 then.