MSHS 2020 Computing P2 Solution
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 EXAMINATIONS SECONDARY FOUR COMPUTING 7155/02 Paper 2 Practical (Lab-based) 28 August 2020 2 hours 30 mins Additional Materials: Electronic version of COMPANY.XLS file Electronic version of DEPOSITS.PY file Electronic version of CASHBACK.PY file Insert Quick Reference for Python READ THESE INSTRUCTIONS FIRST SOLUTION For Examiner’s Use This document consists of 6 printed pages. 50 Thumb drive No:
2 Task 1 Question Answer Marks 1 =MID(D4;10;2) =MID(D5;10;2) =MID(D6;10;2) =MID(D7;10;2) =MID(D8;10;2) =MID(D9;10;2) =MID(D10;10;2) =MID(D11;10;2) =MID(D12;10;2) Acceptable: RIGHT(D4;2) This is in the next syllabus but not in current syllabus 2 Question Answer Marks 2 =VLOOKUP(E4;$B$18:$C$22; 2) =VLOOKUP(E5;$B$18:$C$22; 2) =VLOOKUP(E6;$B$18:$C$22; 2) =VLOOKUP(E7;$B$18:$C$22; 2) =VLOOKUP(E8;$B$18:$C$22; 2) =VLOOKUP(E9;$B$18:$C$22; 2) =VLOOKUP(E10;$B$18:$C$22; 2) =VLOOKUP(E11;$B$18:$C$22; 2) =VLOOKUP(E12;$B$18:$C$22; 2) 2 Question Answer Marks 3 =G4*H4 =G5*H5 =G6*H6 =G7*H7 =G8*H8 =G9*H9 =G10*H10 =G11*H11 =G12*H12 1 Answer Marks =F4+I4 =F5+I5 =F6+I6 =F7+I7 =F8+I8 =F9+I9 =F10+I10 =F11+I11 =F12+I12 1
3 Question Answer Marks 4 Total Cost $270.00 $510.00 $160.00 $260.00 $327.00 $475.00 $170.00 $235.00 $260.00 1 Question Answer Marks 5 =SUM(J4:J12) 1 Question Answer Marks 6 =LARGE(G4:G12;2) 2 Task 2 Question Answer Marks 7 if names[i].startswith('D'): 1 8(a) print("The total amount of deposits are: ", sum(deposits)) 2 8(b) print("The average amount of deposit is: ", round(sum(deposits)/len(deposits))) 3 8(c) for i in range(len(names)): if names[i].endswith('n') and len(names[i]) == 4: print("Customer name is {}, Deposit amount is {}".format(names[i], deposits[i])) 4 MYDEPOSITS.PY names = ['Joy', 'Mary', 'John', 'Dean', 'Siva'] deposits = [540.35, 525.60, 539.50, 500.05, 570.95] for i in range(len(names)): if names[i].startswith('D'): print("Customer name is {}, Deposit amount is {}".format(names[i], deposits[i])) print("The total amount of deposits are: ", sum(deposits)) print("The average amount of deposit is: ", round(sum(deposits)/len(deposits))) for i in range(len(names)): if names[i].endswith('n') and len(names[i]) == 4: print("Customer name is {}, Deposit amount is {}".format(names[i], deposits[i]))
4 Task 3 Question Answer Marks 9 Errors are underlined customers = False count = 10 while customers == True: exp = int(input("Enter expenditure for quarter: ")) rewards = int(input("Enter rewards accumulated: ")) if exp >= 500 and rewards >= 1000: print("Customer receives 5 percent cashback.") count = count += 1 elif exp > 300 and rewards >= 700: print("Customer receives 3 percent cashback.") elif exp >= 200: print("Customer receives 2 percent cashback.") else print("No cashback discount."") more_cust = int(input("Any more customers? Type Y or N: ")) if more_cust == 'Y': customers = False else: customers = False print("Total customers who qualify for 5 percent cashback are: " + count) Corrected Lines 1 customers = True 1 2 count = 0 1 3 if exp >= 500 or rewards >= 1000: 1 4 count = count + 1 1 5 elif exp >= 300 and rewards >= 700: 1 6 else: 1 7 print("No cashback discount.") 1 8 more_cust = input("Any more customers? Type Y or N: " 1 9 if more_cust == 'Y': customers = True 1 10 print("Total customers who qualify for 5 percent cashback are: " + str(count)) OR print("Total customers who qualify for 5 percent cashback are: " , count) 1
5 Task 4 Question Answer Marks 10 Print 6 chances at the start Ask for user input of a word with 6 or fewer letters Validation of word Ask user to re-enter with correct message while len(word) > 6: word = input("Please re-enter a word with maximum of 6 letters: ") Create a new list with length equal to that of the word. Use of a loop with correct terminating condition Ask for input of a letter Checks if letter is found within the word Output “Letter found in word.” if letter is found. Output “Letter not found.” if letter is not found. Question Answer Marks 11 Screenshot of Test 1 Screenshot of Test 2 Question Answer Marks 12 Create a new list to store indexes Check if letter is found in word Stores all index(es) of the word where letter is found Using the indexes, update the list to overwrite character with letter found Output the list to show all found letters Check chances used up Output "Game over. All chances used!" If user guesses all letters correctly before 6 chances are used Output “You win!” and break Sample Code: #TASK 4 WORDGUESS2.PY print("You have 6 chances to guess a word.") #1m word = input("Enter a word to guess. Must be 6 or fewer letters: ") #1m while len(word) > 6: #2m for validation of length word = input("Please re-enter a word with maximum of 6 letters: ") guess = list('-' * len(word)) #1m print(guess)
6 CHANCES = 6 count = 0 while CHANCES > 0: #2m outer loop for 6 chances letter = input("Enter a letter: ") #1m if letter in word: #1m print("Letter found in word.") indexes = [] #1m for i in range(len(word)): if word[i] == letter: #1m indexes.append(i) #1m for index in indexes: #1m guess[index] = letter #1m print(guess) #1m if "-" not in guess: #1m print("You win!") break else: print("Letter not found.") #1m CHANCES = CHANCES - 1 if CHANCES == 0: #1m print("Game over. All chances used!") -End of Paper-
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

