Class 7 Computer Science — Combining conditions with and, or and not
Work out whether a condition joined by and, or or not comes out true, and which branch a program takes because of it.
Name: ________________________
1.A condition says: the number is more than 5 or the number is more than 50. Which numbers make it true?
- a) Only the numbers above 50
- b) Only the numbers between 5 and 50
- c) Every number above 5
- d) No number at all
2.A program says: if the number is more than 10 and less than 20, print "Middle"; otherwise print "Outside". The number is 25. What does it print?
3.A program says: if the mark is less than 33 or the attendance is less than 75, print "Not allowed"; otherwise print "Allowed". The mark is 90 and the attendance is 60. What does it print?
4.A program says: if the mark is less than 33 or the attendance is less than 75, print "Not allowed"; otherwise print "Allowed". The mark is 20 and the attendance is 95. What does it print?
5.A program prints "Go" only when the light is green and the road is clear, and prints "Wait" otherwise. Sort each situation by what it prints.
Groups: Go · Wait
- The light is red and the road is blocked
- The light is green and nothing is standing on the road
- The light is green and the road is clear
- The light is green and the road is blocked
- The light is red and the road is clear
6.A program says: if the number is more than 10 and less than 20, print "Middle"; otherwise print "Outside". The number is 12. What does it print?
7.A condition says: the number is more than 50 and the number is less than 10. Which numbers make it true?
- a) The numbers between 10 and 50
- b) Only 10 and 50 themselves
- c) No number at all
- d) Every number
8.Match each condition to the smallest whole number that makes it true.
- more than 3 and more than 7
- more than 3 or more than 7
- at least 5 and at least 9
- at least 5 or at least 9
- more than 0 and at least 2
- 2
- 8
- 4
- 9
- 5
Answer key — Class 7 Computer Science — Combining conditions with and, or and not
- 1. c) Every number above 5
- 2. Outside
- 3. Not allowed
- 4. Not allowed
- 5. The light is green and the road is clear → Go; The light is green and the road is blocked → Wait; The light is red and the road is clear → Wait; The light is red and the road is blocked → Wait; The light is green and nothing is standing on the road → Go
- 6. Middle
- 7. c) No number at all
- 8. more than 3 and more than 7 → 8; more than 3 or more than 7 → 4; at least 5 and at least 9 → 9; at least 5 or at least 9 → 5; more than 0 and at least 2 → 2