9618/23/O/N/23 question 1: worked solution (October/November 2023, paper 23)

Show as plain text

Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3. Q17 9618/23/O/N/23 original Q1 Structured · 11 marks Worked solution (a) Work out what kind of value each assignment stores: Assignment statement Data type MyVar1 ← Total1 / Total2 REAL MyVar2 ← 27/10/2023 DATE MyVar3 ← "Sum1 / Sum2" STRING MyVar4 ← Result1 AND Result2 BOOLEAN MyVar1 is REAL (a division can give a decimal) [1] MyVar2 is DATE [1] MyVar3 is STRING (it is in quotes) [1] MyVar4 is BOOLEAN (AND gives TRUE or FALSE) [1] (b) Evaluate each expression with Active = TRUE, Fraction = 0.2, Code = "Ab12345": Expression Evaluates to Fraction >= 0.2 AND NOT Active FALSE INT((Fraction * 100) + 13.3) 33 STR_TO_NUM(MID(Code, 4, 2)) + 5 28 LENGTH("TRUE" & Code) 11 Fraction >= 0.2 is TRUE, NOT Active is FALSE, so TRUE AND FALSE = FALSE [1] 0.2 × 100 = 20, 20 + 13.3 = 33.3, INT gives 33 [1] MID(Code, 4, 2) = "23", converted to 23, 23 + 5 = 28 [1] "TRUE" & Code = "TRUEAb12345", which has 4 + 7 = 11 characters [1] (c) Write: use a program library (a library of ready-made routines). [1] (d) Write both parts: Type: adaptive maintenance [1] Reason: the user requirements change (or the law changes, so the program must change) [1] KEY IDEA Match each data type to the value stored and evaluate expressions one function at a time. TOTAL 11 marks Official mark scheme VIDEO ▶ Starts at Q1 (1:52) Starts at Q1 (1:52) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.