Flowcharts that choose
Answers are for parents and teachers.
1
Trace the flowchart for 12 guests, 13 guests and 5 guests.
12 guests: 12 > 12 is no, so ‘Small table’. 13 guests: yes, so ‘Big table’. 5 guests: no, so ‘Small table’.
2
Draw a flowchart: the user enters the number of goals. If there are more than 2 it outputs ‘Great match’, otherwise it outputs ‘Good effort’.
Start, INPUT goals, a diamond goals > 2?, yes to OUTPUT Great match, no to OUTPUT Good effort, Stop.
3
Fill in the operator for each phrase.
| In words | Condition |
|---|---|
| fewer than 20 | pupils ? 20 |
| at least 7 | days ? 7 |
| exactly 9 | answer ? 9 |
| not 3 | number ? 3 |
fewer than 20: <; at least 7: >=; exactly 9: ==; not 3: !=.
4
The user types 5 in one run and 4 in another. What does the program show each time?
Python
1temp = int(input("Temperature? ")) 2if temp < 5: 3 print("Frost warning") 4else: 5 print("No warning")
For 5 it shows No warning, because 5 < 5 is false. For 4 it shows Frost warning.
5
Explain the difference between = and ==, and between sequence and selection.
= stores a value in a variable, but == compares two values and gives true or false. In a sequence the steps run one after another, but in a selection a condition decides which path is followed.