One question, two roads
Answers are for parents and teachers.
1
Write a condition for each. (a) The ticket costs less than 10. (b) The tank is not empty (variable fuel). (c) At most 4 pupils can sit at one table.
(a) price < 10. (b) fuel != 0. (c) pupils <= 4.
2
Follow the algorithm for the inputs 8 and 15. What is shown each time?
Pseudocode
1INPUT seats 2IF seats >= 10 THEN 3 OUTPUT "Large" 4ELSE 5 OUTPUT "Small" 6ENDIF
8: Small. 15: Large. 8 >= 10 is false, so Small. 15 >= 10 is true, so Large.
3
Write pseudocode: the user types the temperature of a fridge. If it is above 5, the program shows Too warm. Otherwise it shows Cold enough.
INPUT temp / IF temp > 5 THEN / OUTPUT "Too warm" / ELSE / OUTPUT "Cold enough" / ENDIF (with the output lines indented).
4
Rewrite the statement IF seats >= 30 THEN ... ELSE ... ENDIF in a different valid style. Say what you changed.
For example: if seats >= 30 then ... else ... endif, written in lower case all the way through. The meaning is the same, and the style is consistent.
5
Why do spaces at the start of lines help a human reader, even though the computer ignores them?
The computer follows the keywords IF, ELSE and ENDIF. Spaces at the start of a line are for people: they show at a glance which lines belong to which branch, so mistakes are easier to spot.