2021 MSHS Computing P2 Solutions
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesClass/ Index Number / Centre Number/ ‘O’ Level Index Number / Name MARIS STELLA HIGH SCHOOL PRELIMINARY EXAMINATION SECONDARY FOUR COMPUTING 7155/02 Paper 2 Practical (Lab-based) 20 August 2021 2 hours 30 mins Additional Materials: Electronic version of REGISTER.XLSX file Electronic version of PRODUCT.PY file Electronic version of GUESS.PY file Insert Quick Reference for Python READ THESE INSTRUCTIONS FIRST MARK SCHEME For Examiner’s Use This document consists of 7 printed pages. 50 Thumb drive No:
2 Task 1 Question Answer Marks 1 Age =$C$25-C3 =$C$25-C4 =$C$25-C5 =$C$25-C6 =$C$25-C7 =$C$25-C8 =$C$25-C9 1 Question Answer Marks 2 Category =VLOOKUP(D3,$K$4:$L$6,2,1) =VLOOKUP(D4,$K$4:$L$6,2,1) =VLOOKUP(D5,$K$4:$L$6,2,1) =VLOOKUP(D6,$K$4:$L$6,2,1) =VLOOKUP(D7,$K$4:$L$6,2,1) =VLOOKUP(D8,$K$4:$L$6,2,1) =VLOOKUP(D9,$K$4:$L$6,2,1) =VLOOKUP(D10,$K$4:$L$6,2,1) =VLOOKUP(D11,$K$4:$L$6,2,1) =VLOOKUP(D12,$K$4:$L$6,2,1) 2 Question Answer Marks 3 Password =CONCATENATE(LEFT(B3,2),LEN(B3),LEFT(F3,1)) =CONCATENATE(LEFT(B4,2),LEN(B4),LEFT(F4,1)) =CONCATENATE(LEFT(B5,2),LEN(B5),LEFT(F5,1)) =CONCATENATE(LEFT(B6,2),LEN(B6),LEFT(F6,1)) =CONCATENATE(LEFT(B7,2),LEN(B7),LEFT(F7,1)) =CONCATENATE(LEFT(B8,2),LEN(B8),LEFT(F8,1)) =CONCATENATE(LEFT(B9,2),LEN(B9),LEFT(F9,1)) 2 Question Answer Marks 4 Student Total =COUNTIF($F$3:$F$23,J10) =COUNTIF($F$3:$F$23,J11) =COUNTIF($F$3:$F$23,J12) 2 Question Answer Marks 5 Total =M16*L16 =M17*L17 1
3 =M18*L18 =M19*L19 Question Answer Marks 6 =SUMIF($J$16:$J$24,M9,$N$16:$N$24) =SUMIF($J$16:$J$24,M10,$N$16:$N$24) =SUMIF($J$16:$J$24,M11,$N$16:$N$24) 2
4 Task 2 Question Answer 7(a) mod = totalcount%11 7(b) if mod == 10: mod = "X" 7(c) CHECKDIGITS = ["1","2","3:","4","5","6","7","8","9","0","X"] while not(len(number)==9 and (number[:-1].isdigit() and number[-1]in CHECKDIGITS)): # 1m for loop, 1m for length check, 1m for format check if len(number)!=9: print("Incorrect length. Only length of 9 allowed.") if not number[:-1].isdigit(): print("First 8 data should only be digits.") if not (number[-1]in CHECKDIGITS): print("Last data should be either a digit or 'X'") number = input("Please re-enter product number: ") # 1m 8 repeat = "Y" while repeat == "Y": repeat = input("Continue with another product code (Y/N)? ").upper() MYPRODUCTCODE.PY WEIGHTS=[3,4,6,8,4,3,5,5] CHECKDIGITS = ["1","2","3","4","5","6","7","8","9","0","X"] #adding validation of length check and format check 4m repeat = "Y" #1m for setting variable while repeat == "Y": #1m for proper loop condition number = input("Please enter product number: ") while not(len(number)==9 and (number[:-1].isdigit() and number[-1]in CHECKDIGITS)): #1m for loop, 1m for length check, 1m for format check if len(number)!=9: print("Incorrect length. Only length of 9 allowed.") if not number[:-1].isdigit(): print("First 8 data should only be digits.") if not (number[-1]in CHECKDIGITS): print("Last data should be either a digit or 'X'") #individual statements for each check not required for marks number = input("Please re-enter product number: ") #re-entry statement MUST be different from first request totalcount=0 for counter in range (8): totalcount = totalcount + WEIGHTS[counter]*int(number[counter]) mod = totalcount%11 #change %10 to %11 1 mark if mod == 10: #add check to change remainder of 10 to X mod = "X" if str(mod) == number[-1]:
5 print("The product number is valid.") else: print("This is an invalid product number.") repeat = input("Continue with another product code (Y/N)? ").upper() #1m to ensure non cap sensitive input required while repeat != "Y" and repeat != "N": repeat = input("Please only input Y or N ").upper() Task 3 Question Answer 9 Errors are highlighted import random count = 1 #1 changed 0 to 1 ans = random.randint(1,100) #2 changed 10 to 100 num = input("Enter a number: ") while not num.isdigit(): #3 added : num = input("Enter only numbers: ") num=int(num) #7 change str to int (both change) while num != ans and count < 8: #4 changed or to and if num < ans: #5 changed > to < print("Your guess is too low!") else: print("Your guess is too high!") num = input("Enter a number: ") while not num.isdigit(): #6 added () num = input("Enter only numbers: ") num=int(num) #7 changed str to int count = count + 1 #8 changed - to + if num == ans: #9 changed != to == print("You guessed it correctly!") else: print("You lost! You didn't get the number.") print("You made {} guesses".format(count)) #10 changed num to count Corrected Lines 1 count = 1 *if this is not changed (see * changes) 2 ans = random.randint(1,100) 3 while not num.isdigit(): 4 while num != ans and count < 8: *8 here will have to change to 7 5 if num < ans: 6 while not num.isdigit(): 7 num=int(num) @note two lines need to be changed 8 count = count + 1 9 if num == ans: 10 print("You made {} guesses".format(count)) *num change to count+1
6 Task 4 Question Answer 10 Ask for Class and store into variable Ask for no of students in class and store into variable Ask for no of candidate and store into variable Ask for input of names and store into variable Adding of Abstain together with choice of names Loop using no of students as a counter Validation of choice of vote Appropriate question when rejected Increment counter based on vote Print out of selection choices Checking for highest vote Placing highest vote names into variable include case of tie Print out votes clearly showing names and votes Question Answer 11 Screenshot of Test 1 Screenshot of Test 2 Screenshot results same as provided screenshot Question Answer 12 Loop created for case of highest elected > 1 Loop repeats more than once for case of repeated ties Check to see if there is a need to restart voting Appropriate message to inform of restarting vote Sample Code: #TASK 4 CLASSVOTE2.PY classroom = input("Name of class: ") noofppl = int(input("Number of students in class: ")) noofcan = int(input("Number of candidates: ")) while noofcan < 0 or noofcan > 4: noofcan = int(input("Re-enter number of candidates (Max = 4): ")) options = input("Enter names of candidates separated with a comma and a space: ").split(", ") while len(options)!=noofcan: options = input("Re-enter the {} names of candidates separated with a comma and a space: ".format(noofcan)).split(", ") highestelected = ["-1"]
7 while highestelected == ["-1"] or len(highestelected) > 1: #1 1 mark loop created for case of highest elected > 1 if len(highestelected)>1: #2 1 mark if loop can repeat more than once (case of repeated ties) options = highestelected options.append("Abstain") numlist = [0]*len(options) for ppl in range(noofppl): print("Each student will now place their votes from the following choice: ") print(options) selection = int(input("Enter your choice from 1 to {}: ".format(len(options)))) while not(selection >=1 and selection <= len(options)): selection = int(input("Please re-enter your choice from 1 to {}: ".format(len(options)))) numlist[selection-1] = numlist[selection-1] + 1
Content continues in the PDF. Download PDF
Related notes
- SST (for revision practice) 2024 S3 Computing EOY P2 QP_FinalExam Papers · 2024
- Computing o level notes Notes/Practices · 2023
- BVSS Prelim P1 MSExam Papers · 2024
- BVSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices
- SST 2024 Prelim Paper 1 Ans [revised for 2025] Exam Papers · 2024
- SST 2024 Prelim Paper 1 [revised for 2025] Exam Papers · 2024
- [Notes for Computing] All Definitions/ TermsNotes/Practices · 2025
- [Notes for Computing] Heavily Compressed TextbookNotes/Practices · 2025
- All Computing Terms/DefinitionsNotes/Practices · 2025
- See all Computing notes

