Year 7 Computing — Making decisions in programs
Test whether a condition is true, and work out which branch of an if-otherwise step a program takes.
Name: ________________________
1.A program says: if the mark is at least 40, print "Pass"; otherwise print "Fail". The mark is 39. What does the program print?
2.Sort each of these statements by whether it is true or false.
Groups: True · False
- 7 is equal to 7
- 5 is less than 2
- 8 is more than 3
- 9 is more than 2
- 4 is more than 4
- 10 is less than 10
3.A program tests a number and takes one of its two branches. In a single run, how many of the two words does it print?
- a) It changes each time
- b) Two
- c) One
- d) None
4.A program says: if the mark is at least 40, print "Pass"; otherwise print "Fail". The mark is 40. What does the program print?
5.A program says: if the number is more than 12, print "Over"; otherwise print "Under". The number is 12. What does the program print?
- a) Nothing at all
- b) Under
- c) Over
- d) Both words
6.Match each condition to the smallest whole number that makes it true.
- More than 5
- More than 9
- At least 3
- More than 0
- At least 12
- 6
- 10
- 1
- 3
- 12
7.Is 7 more than 10?
- a) No
- b) There is no way to tell
- c) Sometimes
- d) Yes
8.In a step that says "if this, do that; otherwise do the other", when does the otherwise part run?
- a) Only when the condition is true
- b) Only when the condition is false
- c) Every single time, after the first part
- d) Never — it is there for decoration
Answer key — Year 7 Computing — Making decisions in programs
- 1. Fail
- 2. 8 is more than 3 → True; 5 is less than 2 → False; 7 is equal to 7 → True; 10 is less than 10 → False; 4 is more than 4 → False; 9 is more than 2 → True
- 3. c) One
- 4. Pass
- 5. b) Under
- 6. More than 5 → 6; More than 9 → 10; At least 3 → 3; More than 0 → 1; At least 12 → 12
- 7. a) No
- 8. b) Only when the condition is false