Logical expressions – practice for Years 7–9
Sample questions on Logical expressions with the right answer and a worked solution, from easy to hard. In the Pickles Academy app a child gets new questions of the same kind every time, so they can't just learn the answers by heart.
- Subject
- Computing
- Year
- Years 7–9
- Curriculum area
- Algorithms and programming
Question types: True or false?
Rule: Logical expressions
and is true only when both parts are true. or is true when at least one is. not turns true into false and back.
First work out the comparisons (<, >, ==, !=), then not, then and, and or last.
Example: x = 3, y = 7: x < 5 and y < 5 is false, x < 5 or y < 5 is true
Watch out: == compares, = gives a variable a value. x != 3 is true when x is not 3.
Sample questions
-
Question 1 Easy
The variables have the values from the first lines. Decide for each expression whether it is true (YES) or false (NO).
a = 5 b = 7 1: a < b 2: a > 5 and b > a 3: a < 6 and a > b
- Expression 1
- Expression 2
- Expression 3
Show the solution
Answer:- Expression 1 – yes
- Expression 2 – no
- Expression 3 – no
How it works: 1. YES: 5 < 7 (true) 2. NO: [5 > 5 (false) and 7 > 5 (true)] 3. NO: [5 < 6 (true) and 5 > 7 (false)]
-
Question 2 Normal
The variables have the values from the first lines. Decide for each expression whether it is true (YES) or false (NO).
a = 5 b = 7 1: a <= b and b >= a 2: not (b >= a) 3: a <= b or b >= a 4: a >= b and b >= 2
- Expression 1
- Expression 2
- Expression 3
- Expression 4
Show the solution
Answer:- Expression 1 – yes
- Expression 2 – no
- Expression 3 – yes
- Expression 4 – no
How it works: 1. YES: [5 <= 7 (true) and 7 >= 5 (true)] 2. NO: not 7 >= 5 (true) 3. YES: [5 <= 7 (true) or 7 >= 5 (true)] 4. NO: [5 >= 7 (false) and 7 >= 2 (true)]
-
Question 3 Hard
The variables have the values from the first lines. Decide for each expression whether it is true (YES) or false (NO).
a = 5 b = 7 c = 8 1: (a % 2 == 0 or b + c > 12) and b % 2 == 0 2: not (b % 2 == 0 and a >= c) 3: (a % 2 != 0 or b < c) and c <= b 4: b % 2 == 0 and c + b > 13 or b < 4 5: (b > 8 or a + b < 13) and a < b
- Expression 1
- Expression 2
- Expression 3
- Expression 4
- Expression 5
Show the solution
Answer:- Expression 1 – no
- Expression 2 – yes
- Expression 3 – no
- Expression 4 – no
- Expression 5 – yes
How it works: 1. NO: [[5 % 2 == 0 (false) or 7 + 8 > 12 (true)] and 7 % 2 == 0 (false)] 2. YES: not [7 % 2 == 0 (false) and 5 >= 8 (false)] 3. NO: [[5 % 2 != 0 (true) or 7 < 8 (true)] and 8 <= 7 (false)] 4. NO: [[7 % 2 == 0 (false) and 8 + 7 > 13 (true)] or 7 < 4 (false)] 5. YES: [[7 > 8 (false) or 5 + 7 < 13 (true)] and 5 < 7 (true)]
Keep practising in the app
In a minute, your child has their own avatar and a first task. Free, no ads, data in the EU.
Start for free