Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q5 · 9618/21/M/J/22 Q1

Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3.

Q59618/21/M/J/22original Q1Structured · 11 marks
Question 1 from 9618/21/M/J/22

Worked solution

(a)

Write: algorithm [1]

(b)(i)

VariableData type
TempREAL
PetNameSTRING
MyDOBDATE
LightOnBOOLEAN

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]

(b)(ii)

Write: variable Temp [1]

Reason: the name does not say what it is used for (it should be something like AverageTemperature) [1]

(c)

ExpressionEvaluation
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]

KEY IDEAPick data types from the use of the data, and evaluate nested functions from the inside outwards.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/21/M/J/22 question 1
VIDEO
▶ 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.