Cambridge A Level Computer Science 9608 — 2015 Oct/Nov Paper 2 · Variant 2

9608/22/O/N/15 · 75 marks · ≈84 min

The question paper and its mark scheme, free to read here and free to download. This is Cambridge’s own paper, exactly as it was sat.

← All Computer Science papersWhat was in this paper?

Question paper16 pages

Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 1 of 16
Page 1 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 2 of 16
Page 2 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 3 of 16
Page 3 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 4 of 16
Page 4 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 5 of 16
Page 5 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 6 of 16
Page 6 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 7 of 16
Page 7 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 8 of 16
Page 8 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 9 of 16
Page 9 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 10 of 16
Page 10 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 11 of 16
Page 11 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 12 of 16
Page 12 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 13 of 16
Page 13 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 14 of 16
Page 14 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 15 of 16
Page 15 of 16
Cambridge A Level Computer Science 9608 2015 Oct/Nov Paper 2 · Variant 2 question paper, page 16 of 16
Page 16 of 16

Mark scheme10 pages

Answers below. Sit the paper first if you are practising.

Mark scheme, page 1 of 10
Page 1 of 10
Mark scheme, page 2 of 10
Page 2 of 10
Mark scheme, page 3 of 10
Page 3 of 10
Mark scheme, page 4 of 10
Page 4 of 10
Mark scheme, page 5 of 10
Page 5 of 10
Mark scheme, page 6 of 10
Page 6 of 10
Mark scheme, page 7 of 10
Page 7 of 10
Mark scheme, page 8 of 10
Page 8 of 10
Mark scheme, page 9 of 10
Page 9 of 10
Mark scheme, page 10 of 10
Page 10 of 10

Paper as text

Question paper, page 1

This document consists of 16 printed pages. DC (NH/CGW) 95376/4 © UCLES 2015 [Turn over * 4 6 3 0 1 0 8 0 0 4 * COMPUTER SCIENCE 9608/22 Paper 2 Fundamental Problem-solving and Programming Skills October/November 2015 2 hours Candidates answer on the Question Paper. No Additional Materials are required. No calculators allowed. READ THESE INSTRUCTIONS FIRST Write your Centre number, candidate number and name in the spaces at the top of this page. Write in dark blue or black pen. You may use an HB pencil for any diagrams, graphs or rough working. Do not use staples, paper clips, glue or correction fluid. DO NOT WRITE IN ANY BARCODES. Answer all questions. No marks will be awarded for using brand names of software packages or hardware. At the end of the examination, fasten all your work securely together. The number of marks is given in brackets [ ] at the end of each question or part question. The maximum number of marks is 75. Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

Question paper, page 2

2 9608/22/O/N/15 © UCLES 2015 Throughout the paper you will be asked to write either pseudocode or program code. Complete the statement to indicate which high-level programming language you will use. Programming language … 1 Computer programs have to evaluate expressions. Study the sequence of pseudocode statements. Give the value assigned to each variable. The statement may generate an error. If so, write ERROR. The & operator is used to concatenate strings. DECLARE N1 : INTEGER DECLARE N2 : INTEGER DECLARE Answer : REAL DECLARE Found : BOOLEAN DECLARE IsValid : BOOLEAN N1 ← 3 N2 ← 9 Answer ← (N1 + N2) / 6 Answer ← 3 * (N1 – 2) + N2 / 2 IsValid ← (N1 > N2) AND (N2 = 9) Found ← FALSE IsValid ← (N1 > N2 / 2) OR (Found = FALSE) Answer ← "1034" & " + " & "65" (i) Answer … [1] (ii) Answer … [1] (iii) IsValid … [1] (iv) IsValid … [1] (v) Answer … [1] To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

Question paper, page 3

3 9608/22/O/N/15 © UCLES 2015 [Turn over 2 A program is to simulate the operation of a particular type of logic gate. • The gate has two inputs (0 or 1) which are entered by the user. • The program will display the output (0 or 1) from the gate. The program uses the following identifiers in the pseudocode below: Identifier Data type Description P INTEGER Input signal Q INTEGER Input signal X INTEGER Output signal 01 INPUT P 02 INPUT Q 03 IF (P = 1 AND Q = 0) OR (P = 0 AND Q = 1) OR (P = 0 AND Q = 0) 04 THEN 05 X ← 0 06 ELSE 07 X ← 1 08 ENDIF 09 OUTPUT X (a) The programmer chooses the following four test cases. Show the output (X) for each test case. Input Output Test case P Q X 1 1 1 2 1 0 3 0 1 4 0 0 [4] (b) The selection statement (lines 03 – 08) could have been written with more simplified logic. Rewrite this section of the algorithm in pseudocode. … … … … … …[3]

Question paper, page 4

4 9608/22/O/N/15 © UCLES 2015 3 Regular customers at a supermarket use a rewards card at the point-of-sale. Points are calculated from every transaction and added to the points total stored on the card. One reward point is given for every $1 spent. When the points total exceeds 500, the customer can either: • pay the full amount due and increase their points total • get $1 deducted from the amount due in exchange for 500 reward points The new points total and amount to be paid is printed on the receipt. A program is to be written with the following specification: • read the points total from the card • process the amount spent • output the amount to be paid and the new points total A user-defined function CalculatePoints has already been coded to calculate the new points earned from the amount spent. Study the following pseudocode: INPUT AmountDue NewPoints ← CalculatePoints(AmountDue) PointsTotal ← PointsTotal + NewPoints IF PointsTotal > 500 THEN OUTPUT "Exchange points?" INPUT Response IF Response = "YES" THEN PointsTotal ← PointsTotal – 500 AmountDue ← AmountDue – 1 ENDIF ENDIF OUTPUT AmountDue, PointsTotal The algorithm is also to be documented with a program flowchart. Complete the flowchart by: • filling in the flowchart boxes • labelling, where appropriate, lines of the flowchart

Question paper, page 5

5 9608/22/O/N/15 © UCLES 2015 [Turn over CALL CalculatePoints(AmountDue) [6]

Question paper, page 6

6 9608/22/O/N/15 © UCLES 2015 4 The standard pack of playing cards has four suits – called Clubs, Diamonds, Hearts and Spades. Each card has a value shown by its number or a name: 1 (Ace), 2, 3, … 10, 11 (Jack), 12 (Queen), 13 (King). The pack of cards has one combination for each suit and value. A program is to be written which simulates a magician dealing all 52 cards from the card pack. The program generates pairs of random numbers: • the first, in the range 1 to 4, to represent the suit • the second, in the range 1 to 13, to represent the card value (a) Explain why the generation of 52 (4 suits x 13 card values) pairs of random numbers will not simulate the dealing of the complete pack. … … …[2] (b) A representation of dealing out the cards is shown below: Suit number Card value 1 2 3 4 5 6 7 8 9 10 11 12 13 1 (Clubs) F F F F F F F F F F T F F 2 (Diamonds) F F F F F F F F F F F F F 3 (Hearts) F F T F F F F F F F F F F 4 (Spades) F F F F F F F F F F F F F The table shows two cards have been dealt so far; the 3 of Hearts and the Jack of Clubs. When each card is dealt, the appropriate cell changes from F to T. The program will output the suit and the card value in the order in which the cards are dealt.

Question paper, page 7

7 9608/22/O/N/15 © UCLES 2015 [Turn over Question 4(b) continues on page 8.

Question paper, page 8

8 9608/22/O/N/15 © UCLES 2015 The program design in pseudocode is produced as follows: 01 DECLARE SuitNum : INTEGER 02 DECLARE CardValue : INTEGER 03 DECLARE DealCount : INTEGER 04 DECLARE NewCard : BOOLEAN 05 DECLARE CardPack … 06 07 CALL InitialiseCardPack 08 DealCount ← 0 09 WHILE DealCount <> 52 10 NewCard ← FALSE 11 WHILE NewCard = FALSE 12 SuitNum ← RANDOM(1,4) // generates a random number 13 CardValue ← RANDOM(1,13) // in the range given 14 IF CardPack[SuitNum, CardValue] = FALSE 15 THEN 16 CardPack[SuitNum, CardValue] ← TRUE 17 NewCard ← TRUE 18 OUTPUT SuitNum, CardValue 19 ENDIF 20 ENDWHILE 21 DealCount ← DealCount + 1 22 ENDWHILE 23 24 // end of main program 25 26 PROCEDURE InitialiseCardPack 27 DECLARE i : INTEGER 28 DECLARE j : INTEGER 29 FOR i ← 1 TO 4 30 FOR j ← 1 TO 13 31 CardPack[i, j] ← FALSE 32 ENDFOR 33 ENDFOR 34 ENDPROCEDURE

Question paper, page 9

9 9608/22/O/N/15 © UCLES 2015 [Turn over Study the pseudocode and answer the questions below: Give the line number for: (i) A statement which marks the end of a count controlled loop. …[1] (ii) The declaration of a local variable. …[1] (iii) The initialisation of a variable used as a counter, but not to control a ‘count controlled’ loop. …[1] (iv) A statement which uses a built-in function of the programming language. …[1] (c) Give the number of procedures used by the pseudocode. …[1] (d) Copy the condition which is used to control a ‘pre-condition’ loop. …[1] (e) Explain the purpose of lines 14 – 19 in the design. … … … … … …[2] (f) Complete the declaration of the global variable at line 05. 05 DECLARE CardPack …[1]

Question paper, page 10

10 9608/22/O/N/15 © UCLES 2015 (g) Line 18 in the design shows which new card is dealt each time. When an Ace, Jack, Queen or King is dealt, the output displays the number for that card, not the name of the card. Card value Card name 1 Ace 11 Jack 12 Queen 13 King A new requirement is to display the name of the card, where appropriate. Write a CASE structure using variable CardValue. Assign to a new variable CardName either: • the card value (2, 3, 4, 5, 6, 7, 8, 9 or 10) • or where appropriate, the card name Ace, Jack, Queen or King … … … … … … … …[4]

Question paper, page 11

11 9608/22/O/N/15 © UCLES 2015 [Turn over 5 A program is to process a set of integers. The integers are stored in an array, Num. The first N elements are to be processed. The pseudocode for this program is shown below: FOR i ← 1 TO (N - 1) j ← 1 REPEAT IF Num[j] > Num[j + 1] THEN Temp ← Num[j] Num[j] ← Num[j + 1] Num[j + 1] ← Temp ENDIF j ← j + 1 UNTIL j = (N – i + 1) ENDFOR (a) (i) Trace the execution of the pseudocode for the value N = 5 and the given array of integers. Num N i j Temp 1 2 3 4 5 5 11 16 13 7 8 [8]

Question paper, page 12

12 9608/22/O/N/15 © UCLES 2015 (ii) State the purpose of the algorithm. … …[1] (iii) Describe what evidence from the trace table suggests that the given pseudocode is inefficient. … …[1] (b) Complete the identifier table documenting the use of each of the variables. Identifier Data type Description Num ARRAY[1:100] OF INTEGER The array of numbers. N i j Temp [5]

Question paper, page 13

13 9608/22/O/N/15 © UCLES 2015 [Turn over 6 Some pseudocode statements follow which use the following built-in functions: ONECHAR(ThisString : STRING, Position : INTEGER) RETURNS CHAR returns the single character at position Position (counting from the start of the string with value 1) from the string ThisString. For example: ONECHAR("Barcelona", 3) returns 'r'. CHARACTERCOUNT(ThisString : STRING) RETURNS INTEGER returns the number of characters in the string ThisString. For example: CHARACTERCOUNT("South Africa") returns 12. (a) Study the following pseudocode statements. Give the values assigned to variables x and y. (i) x ← CHARACTERCOUNT("New Delhi") + 3 x … [1] (ii) y ← ONECHAR("Sri Lanka", 5) y … [1] (b) A program is to be written as follows: • the user enters a string • the program will form a new string with all <Space> characters removed • the new string is output NewString ← " " INPUT InputString j ← CHARACTERCOUNT(InputString) FOR i ← 1 TO j NextChar ← ONECHAR(InputString, i) IF NextChar <> " " THEN // the & character joins together two strings NewString ← NewString & NextChar ENDIF ENDFOR OUTPUT NewString (i) Complete the identifier table below. Identifier Data type Description InputString STRING The string value input by the user [4]

Question paper, page 14

14 9608/22/O/N/15 © UCLES 2015 (ii) An experienced programmer suggests this pseudocode would be best designed as a function. Complete the re-design of the pseudocode as follows: The main program: • the user enters MyString • the function is called and the changed string is assigned to variable ChangedString The function: • has identifier RemoveSpaces • has a single parameter • will include the declaration for any local variables used by the function // main program INPUT MyString ChangedString ← RemoveSpaces(…) OUTPUT ChangedString // function definition FUNCTION RemoveSpaces(…) RETURNS … … … … … j ← CHARACTERCOUNT(InputString) FOR i ← 1 TO j NextChar ← ONECHAR(InputString, i) IF NextChar <> " " THEN // the & character joins together two strings NewString ← NewString & NextChar ENDIF ENDFOR … ENDFUNCTION [7]

Question paper, page 15

15 9608/22/O/N/15 © UCLES 2015 [Turn over 7 ASCII character codes are used to represent a single character. Part of the code table is shown below. ASCII code table (part) Character Decimal Character Decimal Character Decimal <Space> 32 I 73 R 82 A 65 J 74 S 83 B 66 K 75 T 84 C 67 L 76 U 85 D 68 M 77 V 86 E 69 N 78 W 87 F 70 O 79 X 88 G 71 P 80 Y 89 H 72 Q 81 Z 90 Some pseudocode statements follow which use these built-in functions: CHARACTERCOUNT(ThisString : STRING) RETURNS INTEGER returns the number of characters in the string ThisString. For example: CHARACTERCOUNT("South Africa") returns 12. CHR(ThisInteger : INTEGER) RETURNS CHAR returns the character with ASCII value ThisInteger. For example: CHR(66) returns 'B'. ASC(ThisCharacter : CHAR) RETURNS INTEGER returns the ASCII value for character ThisCharacter. For example: ASC('B') returns 66. (a) Give the values assigned to the variables A, B, C and D. The & operator is used to concatenate two strings. The expression could generate an error; if so, write ERROR. Num1 ← 5 A ← ASC('F') + Num1 + ASC('Z') (i) A … [1] B ← CHR(89) & CHR(69) & CHR(83) (ii) B … [1] C ← CHARACTERCOUNT(B & "PLEASE") (iii) C … [1] D ← ASC(ONECHAR("CURRY SAUCE", 7)) (iv) D … [1]

Question paper, page 16

16 9608/22/O/N/15 © UCLES 2015 (b) A program is to be written to input a message string and then encrypt the message. Study the following pseudocode: OUTPUT "Enter message" INPUT MyMessage EncryptString ← " " FOR i ← 1 TO CHARACTERCOUNT(MyMessage) NextNum ← ASC(ONECHAR(MyMessage, i) + 3) EncryptString ← EncryptString & CHR(NextNum) ENDFOR OUTPUT EncryptString (i) Write the above pseudocode algorithm as program code. Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type. Programming language … … … … … … … … … … … … … …[8] (ii) Describe the encryption algorithm used to encrypt the message st ring entered by the user. … … … …[2]

Mark scheme, page 1

® IGCSE is the registered trademark of Cambridge International Examinations. CAMBRIDGE INTERNATIONAL EXAMINATIONS Cambridge International Advanced Subsidiary and Advanced Level MARK SCHEME for the October/November 2015 series 9608 COMPUTER SCIENCE 9608/22 Paper 2 (Written Paper), maximum raw mark 75 This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the details of the discussions that took place at an Examiners’ meeting before marking began, which would have considered the acceptability of alternative answers. Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for Teachers. Cambridge will not enter into discussions about these mark schemes. Cambridge is publishing the mark schemes for the October/November 2015 series for most Cambridge IGCSE®, Cambridge International A and AS Level components and some Cambridge O Level components.

Mark scheme, page 2

Page 2 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 1 (i) 2 [1] (ii) 7.5 [1] Accept: 7 ½ (iii) FALSE [1] (iv) TRUE [1] (v) ERROR [1] 2 (a) Inputs Output Test Case P Q X 1 1 1 1 [1] 2 1 0 0 [1] 3 0 1 0 [1] 4 0 0 0 [1] (b) IF P = 1 AND Q = 1 THEN X ← 1 ELSE X ← 0 ENDIF IF P = 0 OR Q = 0 THEN X ← 0 ELSE X ← 1 ENDIF Mark as follows: Structure: IF – THEN – ELSE – ENDIF [1] Condition: P = 1 AND Q = 1 [1] Allow &/&& for the operator Logic: X ← 1 (for TRUE) X ← 0 (for FALSE) [1] Check carefully for: • other alternative correct algorithm • a ‘mirror copy’ of the question paper algorithm – score 0

Mark scheme, page 3

Page 3 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 3 [Max 6] START STOP INPUT Amount(Due) PointsTotal > 500 Response = “YES”? AmountDue = AmountDue - 1 PointsTotal = PointsTotal - 500 INPUT Response CALL CalculatePoints(AmountDue) OUTPUT AmountsDue, PointsTotal PointsTotal = PointsTotal + NewPoints OUTPUT “Exchange points?” YES YES START and STOP/END to score A. CALCULATE points total In general – accept descriptive assignment statements Condition + at least one label to score A. True/Tick Allow yes/Yes/missing quotes

Mark scheme, page 4

Page 4 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 4 (a) The combination of suit and card number // the ‘pair ‘ of numbers // the pair of random numbers …. [1] There will be duplicates/repeats//not all cards will be drawn [1] (b) (i) 32 // 33 [1] (ii) 27 // 28 [1] (iii) 08 [1] (iv) 12 // 13 [1] (c) 1 [1] (d) DealCount <> 52 // NewCard = FALSE Allow: Inclusion of the WHILE [1] (e) Test has the card has already been drawn? [1] Set value TRUE for this card entry (in the array)/this card [1] Flags that this is the first time this card has been drawn // decides if another card must be generated [1] Outputs the new card value [1] [Max 2] (f) CardPack ARRAY[1:4 , 1:13] OF/:/AS BOOLEAN [1] Allow: parentheses (g) Pseudocode … (SELECT) CASE (OF) CardValue + ENDCASE [1] (CASE) 1: CardName ← "Ace" 1 mark for any one correct [1] (CASE) 11: CardName ← "Jack" (CASE) 12: CardName ← "Queen" (CASE) 13: CardName ← "King" (final three cases …) [1] OTHERWISE (/ELSE) CardName ← CardValue // (CASE) 2 TO 10: CardName ← CardValue) [1] ENDCASE // ENDSELECT Note: Must be double quotes present and correct case

Mark scheme, page 5

Page 5 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 Visual Basic Select Case CardValue Case 1 CardName = "Ace" Case 11 CardName = "Jack" Case 12 CardName = "Queen" Case 13 CardName = "King" Case Else // Case 2 to 10 CardName = Str(CardValue) [4] End Select Allow: omission of Str

Mark scheme, page 6

Page 6 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 5 (a) (i) [8] (ii) To sort / to order/put in ascending order the items (in the array) [1] (iii) There were no swaps on the last pass / on pass 4 [1] N i j Temp 1 2 3 4 5 11 16 13 7 8 5 1 1 2 13 16 3 7 16 4 8 16 5 2 1 2 7 13 3 8 13 4 3 1 7 11 2 8 11 3 4 1 final values are: 2 7 8 11 13 16 Note these final values will not be shown on the same row … Must be: • Preceded by other entries … • nothing after the 1, 2 sequence Terminates at 5 and 4 respectively

Mark scheme, page 7

Page 7 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 (b) Identifier Data Type Description Num N INTEGER The number of numbers in the list i INTEGER Loop counter // The number of ‘passes’ up through the list j INTEGER The index // position in the array Temp INTEGER Description must imply/states the ‘swapping’ operation Mark as follows: INTEGER × 4 [1] One mark per description [4] 6 (a) (i) 12 [1] (ii) ‘L’ [1] Note: quotes are optional – must be upper case L (b) (i) Identifier Data Type Description InputString STRING The string value input by the user i INTEGER Loop counter // (index) position of an individual character [1] j INTEGER Number of characters in / length of InputString [1] NextChar CHAR//CHARACTER (Single) character within InputString / from string input by the user [1] NewString STRING The string formed/made/created//output Allow: if “by the user” added [1] Note: Correct (identifier + the data type + description) needed to score

Mark scheme, page 8

Page 8 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 (ii) // main program INPUT MyString ChangedString ← RemoveSpaces(MyString) OUTPUT ChangedString // function definition FUNCTION RemoveSpaces(InputString : STRING) RETURNS STRING DECLARE i :/AS INTEGER DECLARE j :/AS INTEGER DECLARE NextChar :/AS CHAR DECLARE NewString :/AS STRING NewString = "" j ← CharacterCount(InputString) FOR i ← 1 TO j NextChar ← OneChar(InputString, i) IF NextChar <> “ “ THEN // the & character joins together two strings NewString ← NewString & NextChar ENDIF ENDFOR only awarded if follows the previous mark RETURN NewString // RemoveSpaces ← NewString ENDFUNCTION [Max 7] 7 (a) (i) 165 [1] (ii) “YES” Quotes optional [1] (iii) 9 [1] (iv) 83 [1] 1 1 1 1 1 1 1 1

Mark scheme, page 9

Page 9 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 (b) (i) Use of correct identifiers only to score Declaration/Commenting of variables MyMessage As String EncryptString As String i As Integer NextNum As Integer At least two variables correctly documented [1] Input of string … Correct syntax (for both prompt and assignment) and … Uses the MyMessage identifier [1] EncryptString set to ‘empty string’ [1] Note: Must suggest ‘empty’ string For loop … FOR – NEXT keywords // (Python) correct indentation [1] Correct start/end boundaries [1] Note: the end boundary must use the language length function/method //alternative Python syntax Isolate single character [1] Use of language functions to calculate new number and …. Assigned to NextNum [1] Conversion of NextNum to a character and concatenated to EncryptString [1] Correct syntax for output of EncryptString [1] [MAX 8] SAMPLE CODE PYTHON MyMessage = input("Enter message : ") EncryptString = "" for i in range(0, len(MyMessage)) : NextNum = ord(MyMessage[i]) + 3 EncryptString = EncryptString + chr(NextNum) print(EncryptString) Alternative solution: MyMessage = input("Enter message : ") EncryptString = "" for NextChar in MyMessage : NextNum = ord(NextChar) + 3 EncryptString = EncryptString + chr(NextNum) print(EncryptString)

Mark scheme, page 10

Page 10 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2015 9608 22 © Cambridge International Examinations 2015 VB Dim MyMessage, EncryptString As String Dim NextNum, i As Integer Console.Write("Enter message : ") MyMessage = Console.ReadLine() EncryptString = "" For i = 1 To Len(MyMessage) NextNum = Asc(Mid(MyMessage, i, 1)) + 3 EncryptString = EncryptString +//& Chr(NextNum) Next Console.WriteLine(EncryptString) Allow: Use of InputBox and MsgBox Alternative solution : Dim MyMessage, EncryptString As String Dim NextNum, i As Integer Console.Write("Enter message : ") MyMessage = Console.ReadLine() EncryptString = "" For i = 0 To Len(MyMessage) - 1 NextNum = Asc(MyMessage.Chars(i)) + 3 EncryptString = EncryptString + Chr(NextNum) Next Console.WriteLine(EncryptString) PASCAL var MyMessage, EncryptString : string; NextNum, i : integer; begin write('Enter message : '); readln(MyMessage); EncryptString := ''; for i := 1 to length(MyMessage) do begin NextNum := ord(MyMessage[i]) + 3; EncryptString := EncryptString + chr(NextNum); end; writeln(EncryptString); end. (ii) For each/every character …. [1] A replacement character is ‘calculated’ from its ASCII value // or by example … [1] Alternatives: GetChar(MyMessage, i) MyMessage.Substring(i, 1)

What you needed in this session

Cambridge’s own grade thresholds for 2015 Oct/Nov, Paper 2 · Variant 2. A higher threshold means an easier paper — the bar moves with how the cohort did.

A54/75
B47/75
C39/75
D31/75
E23/75