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

9608/23/O/N/17 · 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 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 1 of 16
Page 1 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 2 of 16
Page 2 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 3 of 16
Page 3 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 4 of 16
Page 4 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 5 of 16
Page 5 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 6 of 16
Page 6 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 7 of 16
Page 7 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 8 of 16
Page 8 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 9 of 16
Page 9 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 10 of 16
Page 10 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 11 of 16
Page 11 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 12 of 16
Page 12 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 13 of 16
Page 13 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 14 of 16
Page 14 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 15 of 16
Page 15 of 16
Cambridge A Level Computer Science 9608 2017 Oct/Nov Paper 2 · Variant 3 question paper, page 16 of 16
Page 16 of 16

Mark scheme12 pages

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

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

Paper as text

Question paper, page 1

This document consists of 14 printed pages and 2 blank pages. DC (JP) 154213 © UCLES 2017 [Turn over * 8 1 7 7 3 0 9 7 8 5 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills October/November 2017 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/23/O/N/17 © UCLES 2017 1 (a) (i) Procedural high-level languages usually support different data types. Give an appropriate data type for each data value in the following table. Data value Data type 27 "27" "27.3" TRUE 27/3/2015 27.3 [6] (ii) State an appropriate data structure to store the individual test scores for a class of students. …[1] (iii) Describe how characters are represented using the ASCII character set. … … … …[2] (b) Functions and procedures are subroutines. Explain why you should use subroutines when designing a program solution. … … … …[2]

Question paper, page 3

3 9608/23/O/N/17 © UCLES 2017 [Turn over (c) The following pseudocode is an example of nested IF statements. IF MyVar = 1 THEN CALL Proc1() ELSE IF MyVar = 2 THEN CALL Proc2() ELSE IF MyVar = 3 THEN CALL Proc3() ELSE OUTPUT "Error" ENDIF ENDIF ENDIF Use pseudocode to write a CASE statement with the same functionality. … … … … … … … …[4] (d) Program coding is a transferable skill. You are given program code written in a high-level language that you have not studied. State two different features of the code that you should be able to recognise. 1 … … 2 … … [2]

Question paper, page 4

4 9608/23/O/N/17 © UCLES 2017 2 The following pseudocode represents a simple algorithm. DECLARE NumberFound, Remainder, Number : INTEGER DECLARE StartNumber, EndNumber, Divisor : INTEGER INPUT StartNumber INPUT EndNumber INPUT Divisor NumberFound 0 FOR Number StartNumber TO EndNumber Remainder MODULUS(Number, Divisor) IF Remainder = 0 THEN OUTPUT Number NumberFound NumberFound + 1 ENDIF ENDFOR OUTPUT "Count: " & NumberFound For the built-in functions list, refer to the Appendix on page 14. (a) Complete the following trace table. StartNumber EndNumber Divisor NumberFound Number Remainder Output 11 13 2 0 [3] (b) Describe the purpose of this algorithm. … … … … … …[3]

Question paper, page 5

5 9608/23/O/N/17 © UCLES 2017 [Turn over (c) Draw a program flowchart to represent this algorithm. Variable declarations are not required in program flowcharts. [10]

Question paper, page 6

6 9608/23/O/N/17 © UCLES 2017 3 (a) A multi-user computer system stores information about users. It uses a 1D array, UserNameArray, of type STRING. There are 100 elements in the array. The format of the string in each element of the array is as follows: <UserID><UserName> • UserID is a six-character string of numerals. • UserName is a variable-length string. Write pseudocode for a procedure, BubbleSort, to perform an efficient bubble sort on UserNameArray. The array is to be sorted in ascending order of UserID. You should assume that UserNameArray has been declared as a global variable. … … … … … … … … … … … … … … … … … … …

Question paper, page 7

7 9608/23/O/N/17 © UCLES 2017 [Turn over … … … … … …[8]

Question paper, page 8

8 9608/23/O/N/17 © UCLES 2017 (b) The value of UserID should be unique for each user but a problem has occurred and repeated UserID values may have been issued. The array is sorted by UserID, so any repeated UserID values will appear in consecutive array elements. A procedure, FindRepeats is required. This will: • compare each element with the previous element and output the UserID and UserName if the UserID is repeated • output the total number of UserIDs that are repeated. For example, the UserNameArray contains the following entries. Array element Comment 122222Jim Moriarty 123456Fred Smith 123456Eric Sykes Repeated User ID 123456Kevin Turvey Repeated User ID 222244Alice Chan 222244Myra Singh Repeated User ID 333333Yasmin Halim For this example, the output is: 123456Eric Sykes 123456Kevin Turvey 222244Myra Singh There are 3 repeated UserIDs If no repeated UserIDs are found, the output is: The array contains no repeated UserIDs

Question paper, page 9

9 9608/23/O/N/17 © UCLES 2017 [Turn over Write program code for the procedure, FindRepeats. You should assume that UserNameArray has been declared as a global variable. 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 … Program code … … … … … … … … … … … … … … … … … … … … … … …[8]

Question paper, page 10

10 9608/23/O/N/17 © UCLES 2017 (c) (i) The FindRepeats procedure forms part of a program. Name three stages in a program development cycle. 1 … 2 … 3 … [3] (ii) The program containing FindRepeats will be created using an IDE. State what is meant by IDE. … …[1] (iii) Name two features provided by an IDE that assist in the program development cycle. 1 … … 2 … … [2] (iv) The procedure, FindRepeats, is written assuming there are 100 elements in UserNameArray. In the main program, the global array, UserNameArray, has been declared with only 50 elements. State the type of error this will cause. …[1]

Question paper, page 11

11 9608/23/O/N/17 © UCLES 2017 [Turn over 4 Numeric formatting converts a numeric value to a string in order to present it in a specific way. In a generic high-level language, formatting is implemented using a mask system. In this system, each character of the mask corresponds to one character of the formatted string. Mask characters have the following meaning: Mask character Meaning # Character must be a digit or a space 0 Character must be a digit Any other mask characters are taken as literal values and are included in the formatted string. (a) Using the mask "###00.00", complete the following table. Use □ to represent a space. The first value has been done for you. Value Formatted string 1327.5 "□1327.50" 1234 7.456 [2] (b) For each row in the following table, define the mask required to produce the formatted output from the given value. □ represents a space. Value Required output Mask 1234.00 "1,234.00" 3445.66 "£3,445.66" 10345.56 "$□ □10,345" [3]

Question paper, page 12

12 9608/23/O/N/17 © UCLES 2017 5 A sports club maintains a record of the email address of each of its members. The details are stored in a text file, EmailDetails.txt. The format of each line of the text file is as follows: <MembershipNumber><EmailAddress> • MembershipNumber is a four-character string of numerals. • EmailAddress is a variable-length string. Membership of the club has increased and a four-character membership number is no longer adequate. A procedure, MakeNewFile, is required to perform the following actions: 1. Create a new file, NewEmailDetails.txt 2. Read a line from file EmailDetails.txt 3. Extend MembershipNumber by adding two leading zero digits (for example, "1234" becomes "001234") 4. Write the new line to file NewEmailDetails.txt 5. Repeat steps 2 to 4 for all lines in the original file. (a) Write pseudocode for the procedure MakeNewFile. For the built-in functions list, refer to the Appendix on page 14. … … … … … … … … … … … … … … … …[8]

Question paper, page 13

13 9608/23/O/N/17 © UCLES 2017 [Turn over (b) A function, IsEmailValid, is to be written to test for a valid email address format. An email address has a valid format if it obeys the following three rules: 1. It contains a single ‘@’ symbol. 2. The ‘@’ symbol must be preceded by at least one character. 3. The ‘@’ symbol must be followed by at least three characters. Choose three different invalid strings to test distinct aspects of the rules. Explain your choice in each case. 1 … Explanation … … … 2 … Explanation … … … 3 … Explanation … … … [6]

Question paper, page 14

14 9608/23/O/N/17 © UCLES 2017 Appendix Built-in functions (pseudocode) In each function, if the function call is not properly formed, the function returns an error. MODULUS(x : INTEGER, y : INTEGER) RETURNS INTEGER returns the remainder when x is divided by y using integer arithmetic. Example: MODULUS(5, 2) returns 1 INT(x : REAL) RETURNS INTEGER returns the integer part of x. Example: INT(27.5415) returns 27 LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of string ThisString. Example: LENGTH("Happy Days") returns 10 LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns leftmost x characters from ThisString. Example: LEFT("ABCDEFGH", 3) returns string "ABC" RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString. Example: RIGHT("ABCDEFGH", 3) returns string "FGH" Operators (pseudocode) Operator Description & Concatenates (joins) two strings Example: "Summer" & " " & "Pudding" produces "Summer Pudding" AND Performs a logical AND on two Boolean values Example: TRUE AND FALSE produces FALSE OR Performs a logical OR on two Boolean values Example: TRUE OR FALSE produces TRUE

Question paper, page 15

15 9608/23/O/N/17 © UCLES 2017 BLANK PAGE

Question paper, page 16

16 9608/23/O/N/17 © UCLES 2017 BLANK PAGE Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity. 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. Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Mark scheme, page 1

® IGCSE is a registered trademark. This document consists of 12 printed pages. © UCLES 2017 [Turn over Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper October/November 2017 MARK SCHEME Maximum Mark: 75 Published 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 International will not enter into discussions about these mark schemes. Cambridge International is publishing the mark schemes for the October/November 2017 series for most Cambridge IGCSE®, Cambridge International A and AS Level components and some Cambridge O Level components.

Mark scheme, page 2

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 2 of 12 Question Answer Marks 1(a)(i) Data value Data type 27 INTEGER "27" STRING "27.3" STRING TRUE BOOLEAN 27/3/2015 DATE // DATETIME 27.3 REAL One mark for each data type Mark first data type given in each case 6 1(a)(ii) 1D Array // 1DList 2 1(a)(iii) • Each character is represented by an unique / corresponding • binary code / integer / value 2 1(b) • When a section of code would be repeated • When a piece of code is needed to perform a specific task • To support modular programming / step wise refinement • Easier to debug / maintain • Built-in / library routines are tried and tested One mark per answer Max 2 1(c) CASE OF MyVar 1: CALL Proc1() 2: CALL Proc2() 3: CALL Proc3() OTHERWISE OUTPUT "Error" ENDCASE One mark for: • First line and ENDCASE • All clauses for 1, 2 and 3 • 'OTHERWISE' clause • OUTPUT statement 4

Mark scheme, page 3

9 © Ques 1( Ques 2( 2( 9608/23 © UCLES 2017 stion (d) Abi • • • • • • • • • Ma Any Acc stion (a) One One One (b) Ma • • • • Acc No • • lity to recog selection iteration s assignme data decla modular s subroutine Specific ty Code form Operators rk as follow y two from a cept by exa e mark for c e mark for c e mark for c rk as follow For a (give Counts the other Outputs e Outputs th cept by exa mark for: ...calculate ...add one Cambridg gnise: statement statement ent statemen arations / st structure / fu e paramete ypes of stat mat s ws: above, or va mple correct Num correct Rem correct Outp ws: en) range o e number o ach numera he count mple e the remai e to Numbe ge Internatio P nts tructures / d unctions / p ers tement, e.g. alid alternat mber column mainder colu put of values of times one ator (only) nder rFound onal AS/A L PUBLISHED Page 3 of 12 Answer data types / procedures / . Input, Out tive Answer n umn e number (n Level – Mar D r use of vari / subroutine put, File op r umerator) i k Scheme ables or obj es erations s an exact d Octobe bjects divisor of th er/Novembe 201 M M M he er 17 Marks Max 2 Marks 3 3

Mark scheme, page 4

9 © Ques 2( 9608/23 © UCLES 2017 stion (c) Cambridge Internatio P onal AS/A L PUBLISHED Page 4 of 12 Answer Level – Mar D r k Scheme October/Novembe 201 M er 17 Marks 10

Mark scheme, page 5

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 5 of 12 Question Answer Marks 2(c) Mark as follows: • One mark for START and STOP / END • One mark for bracketed pair • One mark for each of other labelled boxes (shape must be correct for decision box) Decision box outputs must have two outputs and at least one label (Yes / No) Different statement categories should not appear in the same symbol (e.g. assignment and I/O) No mark for symbol (or pair) if parent missing or logically incorrect (except for START/END) Full marks should be awarded for functionally equivalent solutions.

Mark scheme, page 6

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 6 of 12 Question Answer Marks 3(a) PROCEDURE BubbleSort DECLARE Temp : STRING DECLARE FirstID, SecondID : INTEGER DECLARE NoSwaps : BOOLEAN DECLARE Boundary : INTEGER Declare J : INTEGER Boundary ← 99 REPEAT NoSwaps ← TRUE FOR J ← 1 TO Boundary FirstID ← UserNameArray[J] SecondID ← UserNameArray[J + 1] IF FirstID > SecondID THEN Temp ← UserNameArray[J] UserNameArray[J] ← UserNameArray[J + 1] UserNameArray[J + 1] ← Temp NoSwaps ← FALSE ENDIF ENDFOR Boundary ← Boundary - 1 UNTIL NoSwaps = TRUE ENDPROCEDURE Mark as follows: 1. Procedure heading and ending (allow array as input parameter) 2. Variable declaration for counter / index (integer) or temp (string) 3. Outer working loop 4. Inner loop with suitable range 5. Correct comparison in a loop 6. Correct swap of complete array element in a loop 7. Set flag to indicate swap in inner loop and resetting in outer loop 8. Reducing Boundary in a loop 8

Mark scheme, page 7

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 7 of 12 Question Answer Marks 3(b) Pseudocode solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. PROCEDURE FindRepeats DECLARE i, RepeatCount: INTEGER DECLARE FirstID, SecondID: STRING RepeatCount ← 0 FOR i ← 2 TO 100 FirstID ← LEFT(UserNameArray[i – 1],6) SecondID ← LEFT(UserNameArray[i],6) IF FirstID = SecondID THEN RepeatCount ← RepeatCount + 1 OUTPUT(UserNameArray[i]) ENDIF ENDFOR IF RepeatCount = 0 THEN OUTPUT "The array contains no repeated UserIDs" ELSE OUTPUT "There are " & RepeatCount & " repeated userIDs" ENDIF ENDPROCEDURE Mark as follows (all must be correct syntax for chosen language): 1. Procedure heading and ending 2. Variable declaration for INTEGER (comment in Python) and initialisation for RepeatCount (or equivalent name) 3. Loop 4. Extraction of UserID in a loop 5. Correct comparison of consecutive elements« in a loop 6. ...output correct array element (NOT original, only duplicates) in a loop 7. increment RepeatCount following a comparison in a loop 8. Correct conditional statement checking RepeatCount (or equivalent) and then ... ... two correct final OUTPUT statements Max 8

Mark scheme, page 8

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 8 of 12 Question Answer Marks 3(c)(i) • Problem definition • Design • Coding / programming • Testing • Documentation • Implementation • Maintenance 3 3(c)(ii) Integrated Development Environment or a suitable description 1 3(c)(iii) Examples include: • context sensitive prompts • (dynamic) syntax checking • use of colours to highlight key words / pretty printing • Formatting • Single-stepping • Breakpoints • Report / watch window • (UML) modelling • Compiler/interpreter • Text editor Max 2 3(c)(iv) Run-time 1 Question Answer Marks 4(a) Value Formatted String 1327.5 "□ 1327.50" 1234 "□ 1234.00" 7.456 "□ □ □ 07.45" Leading spaces must be present 2 4(b) Value Required output Mask 1234.00 "1,234.00" "0,000.00" 3445.66 "£3,445.66" "£0,000.00" 10345.56 "$□ □10,345" "$##00,000" Currency and ‘punctuation’ symbols must be as shown 3

Mark scheme, page 9

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 9 of 12 Question Answer Marks 5(a) PROCEDURE MakeNewfile DECLARE OldFileLine : STRING DECLARE NewFileLine : STRING OPENFILE "EmailDetails" FOR READ OPENFILE "NewEmailDetails" FOR WRITE WHILE NOT EOF("EmailDetails") READFILE "EmailDetails", OldFileLine NewFileLine ← "00" & OldFileLine WRITEFILE "NewEmailDetails", NewFileLine ENDWHILE CLOSEFILE "EmailDetails" CLOSEFILE "NewEmailDetails" ENDPROCEDURE Mark as follows: 1. Variable declaration of STRING for OldFileLine (or equivalent) 2. Open EmailDetails for READ 3. Open NewEmailDetails for WRITE 4. Correct loop checking for EOF(EmailDetails) 5. Reading a line from EmailDetails in a loop 6. Correct concatenation in a loop 7. Writing a line to NewEmailDetails in a loop Closing both files 8 5(b) Invalid string examples: A string with nothing before ‘@’ A string with nothing after ‘@’ A string with 1 or 2 characters after ‘@’ A string with no ‘@’symbol A string with more than one ‘@’ symbol Explanation Sensible explanation mapping each given string to an individual rule One mark for string One mark for explanation Each rule should be tested once only 6

Mark scheme, page 10

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 10 of 12 Programming Example Solutions Q3(b): Visual Basic Sub FindRepeats() Dim Repeats As Integer Dim i As Integer Dim FirstID As String Dim SecondID As String Repeats = 0 For i = 1 To 99 FirstID = Left(UserNameArray(i), 6) SecondID = Left(UserNameArray(i + 1), 6) If FirstID = SecondID Then Console.WriteLine(UserNameArray(i + 1)) Repeats = Repeats + 1 End If Next i If Repeats = 0 Then Console.WriteLine(“The array contains no repeated UserIDs") Else Console.WriteLine(“There are “ & Repeats & " repeated UserIDs") End If End Sub Alternative: Sub FindRepeats () Dim RepeatCount, i As Integer Dim FirstID, SecondID As String RepeatCount = 0 For i = 1 to 99 FirstID = Left(UserNameArray(i-1),6) SecondID = Left(UserNameArray(i),6) If FirstID = SecondID then Console.WriteLine (UserNameArray(i)) RepeatCount = RepeatCount + 1 End If Next i If RepeatCount = 0 then Console.WriteLine ("The array contains no repeated UserIDs") Else Console.WriteLine ("There are "& RepeatCount & " repeated UserIDs") End If End Sub

Mark scheme, page 11

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 11 of 12 Q3(b): Pascal procedure FindRepeats (); var RepeatCount, i : integer; FirstID, SecondID : string; begin RepeatCount := 0; for i := 1 to 99 do begin FirstID := Copy(UserNameArray[i-1],1,6); SecondID := Copy(UserNameArray[i],1,6); if FirstID = SecondID then begin writeln (UserNameArray[i]); RepeatCount := RepeatCount + 1; end; end; if RepeatCount = 0 then writeln ('The array contains no repeated UserIDs') else writeln ('There are ', RepeatCount,' repeated UserIDs') end;

Mark scheme, page 12

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED October/November 2017 © UCLES 2017 Page 12 of 12 Q3(b): Python def FindRepeats(): #Repeats, i Integer #FirstID, SecondID string Repeats = 0 for i in range(0, len(UserNameArray)-1): FirstID = (UserNameArray[i])[:6] SecondID = (UserNameArray[i+1])[:6] if FirstID == SecondID: print(UserNameArray[i+1]) Repeats = Repeats + 1 if Repeats == 0: print("The array contains no repeated UserIDs") else: print(“There are “, Repeats, " repeated UserIDs") Alternative: def FindRepeats (): RepeatCount = 0 ## Defined as an integer for i in range (1,100): ## depending on next two lines(0,99) (2,101) FirstID = UserNameArray[i-1] ## Defined as string SecondID = UserNameArray[i] ## Defined as string if FirstID[0:6] == SecondID[0:6]: ## Using split print (UserNameArray[i]) RepeatCount += 1 if repeatCount == 0: print ('The array contains no repeated UserIDs') else: print ('There are ', RepeatCount,' repeated UserIDs')

What you needed in this session

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

A48/75
B41/75
C33/75
D25/75
E18/75