Computing · Years 5-6
Bell.Study
Conditions and decisions in programs
Using IF, ELSE and comparisons to make programs choose what to do
- 1
What does a condition in a program always evaluate to? A) True or false B) A long sentence C) A picture D) A random number every time
Answer: - 2
Match each comparison symbol to its meaning. Match each item on the left to one on the right. Left: =, <, >, != Right: equal to, less than, greater than, not equal to
Answer: - 3
True or false? The condition 10 > 5 is true. The condition 10 > 5 evaluates to true. A) True B) False
Answer: - 4
Which keyword runs a block of code ONLY IF a condition is false (after an IF)? A) ELSE B) WHILE C) REPEAT D) OUTPUT
Answer: - 5
Look at the condition: IF temperature > 25 THEN OUTPUT 'Hot'. The temperature is 20. What will happen? A) Nothing - the condition is false so the OUTPUT is skipped B) It prints 'Hot' anyway C) It causes an error D) It prints 20
Answer: - 6
Match each logical operator to what it does. Match each item on the left to one on the right. Left: AND, OR, NOT, = Right: True only if BOTH sides are true, True if AT LEAST ONE side is true, Flips true to false and false to true, Tests if two values are equal
Answer: - 7
A program says: IF age >= 13 AND age <= 19 THEN OUTPUT 'Teen'. Which age would NOT print 'Teen'? A) 12 B) 13 C) 16 D) 19
Answer: - 8
A program has IF/ELSE IF/ELSE. How many branches will actually run for a single check? A) Exactly one B) All of them C) Two of them D) None of them
Answer: - 9
What does this output? SET points TO 75 IF points >= 90 THEN OUTPUT 'Gold' ELSE IF points >= 70 THEN OUTPUT 'Silver' ELSE OUTPUT 'Bronze' END IF A) Silver B) Gold C) Bronze D) Nothing
Answer: - 10
Match the condition with the result when x = 8. Match each item on the left to one on the right. Left: x > 5, x < 5, x == 8, x != 8 Right: True, False, True, False
Answer:
Answer key
Conditions and decisions in programs · for parents and teachers
- 1
True or false
A condition is a Boolean expression. It is always either true or false, and the program uses that result to decide what to do.
- 2
= → equal to; < → less than; > → greater than; != → not equal to
These are comparison operators. They compare two values and give back true or false.
- 3
True
Yes, 10 is greater than 5, so the condition 10 > 5 is true.
- 4
ELSE
ELSE provides the code to run when the IF condition is false. Together they let the program choose between two paths.
- 5
Nothing - the condition is false so the OUTPUT is skipped
20 is not greater than 25, so the condition is false. The OUTPUT line is skipped and nothing happens.
- 6
AND → True only if BOTH sides are true; OR → True if AT LEAST ONE side is true; NOT → Flips true to false and false to true; = → Tests if two values are equal
AND, OR and NOT are logical operators. They combine or flip conditions to build more powerful tests.
- 7
12
The condition needs age to be at least 13 AND no more than 19. 12 fails the first part, so 'Teen' is not printed.
- 8
Exactly one
IF/ELSE IF/ELSE picks exactly one branch: the first true condition wins, or ELSE runs if all are false.
- 9
Silver
75 fails the >= 90 test, then passes the >= 70 test, so 'Silver' is printed. The ELSE is skipped.
- 10
x > 5 → True; x < 5 → False; x == 8 → True; x != 8 → False
Use the value of x to work out each condition.