Build it yourself
Answers are for parents and teachers.
1
Plan this problem in three steps and write the pseudocode. A tap sign: the user types the water temperature. Over 40 it shows Too hot, otherwise Safe to use.
Step 1: temp > 40. Step 2: OUTPUT "Too hot". Step 3: OUTPUT "Safe to use". Pseudocode: INPUT temp / IF temp > 40 THEN / OUTPUT "Too hot" / ELSE / OUTPUT "Safe to use" / ENDIF.
2
Follow the algorithm for 0, 1, 3, 4, 5 and 7 coins. What is output each time?
Pseudocode
1INPUT coins 2IF coins >= 5 THEN 3 OUTPUT "Large" 4ELSEIF coins >= 3 THEN 5 OUTPUT "Medium" 6ELSEIF coins >= 1 THEN 7 OUTPUT "Small" 8ELSE 9 OUTPUT "No snack" 10ENDIF
0: No snack. 1: Small. 3: Medium. 4: Medium. 5: Large. 7: Large.
3
Follow the flowchart when the user types 4, 10 and 6. What is output?
total is 4, then 14, then 20. The output is 20. The counter goes 1, 2, 3, and 4 fails the test.
4
Write pseudocode. The user types the ages of 5 players. Output how many of them are 12 or older.
count ← 0 / FOR p ← 1 TO 5 / INPUT age / IF age >= 12 THEN / count ← count + 1 / ENDIF / NEXT p / OUTPUT count. For 11, 13, 9, 12 and 10 the output is 2.
5
Why must total ← 0 be written before the loop?
The first time round, total + value needs a starting value, so the total must have a value before the loop. If total ← 0 were inside the loop, it would reset every time and only the last value would be left.