Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3.
Write: algorithm [1]
| Variable | Data type |
|---|---|
| Temp | REAL |
| PetName | STRING |
| MyDOB | DATE |
| LightOn | BOOLEAN |
Temp: REAL, as an average can have decimals [1]
PetName: STRING [1]
MyDOB: DATE [1]
LightOn: BOOLEAN, as it is only on or off [1]
Write: variable Temp [1]
Reason: the name does not say what it is used for (it should be something like AverageTemperature) [1]
| Expression | Evaluation |
|---|---|
| INT((31 / 3) + 1) | 11 |
| MID(TO_UPPER("Version"), 4, 2) | "SI" |
| TRUE AND (NOT FALSE) | TRUE |
| NUM_TO_STR(27 MOD 3) | "0" |
31 / 3 = 10.33, + 1 = 11.33, INT gives 11 [1]
"VERSION", characters 4 and 5: "SI" [1]
NOT FALSE = TRUE, TRUE AND TRUE = TRUE [1]
27 MOD 3 = 0, as a string: "0" [1]
▶ Whole paper
Video solution of the whole paper · by CS BY AQIB KHAN. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.