Cambridge AS Level Computer Science 9618 · 11.2 Constructs

Q47 · 9618/21/O/N/23 Q1

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

Q479618/21/O/N/23original Q1Structured · 11 marks
Question 1 from 9618/21/O/N/23

Worked solution

(a)

Work through the CASE clauses in order.

Answer
Level when ThisValue is 40"Medium"
Check when ThisValue is 3612
Level when ThisValue is 18"Low"
Elements of Data that may be incremented11

40 is in 30 TO 40, so "Medium" [1]

36 / 3 = 12 [1]

18 is less than 30 (the first clause), so "Low" [1]

Values 30 to 40 give 40 - 30 + 1 = 11 elements [1]

(b)

Write: the assignment Level ← "Very Low" is never performed [1]

Write: because the clauses are checked in order [1]

Write: any value below 30 matches the first clause, so the < 20 clause is never reached [1]

(c)

Write: every possible value is already handled by the other four clauses, so there is no value left for OTHERWISE [1]

(d)

ThisValue: INTEGER [1]

Check: REAL (a division can give a fraction) [1]

Level: STRING [1]

KEY IDEAA CASE checks clauses from the top, so an earlier broader clause can hide a later one.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/21/O/N/23 question 1
VIDEO
▶ Starts at Q1 (0:23)

Starts at Q1 (0:23) · by Pseudocode Pro. 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.