SRSS 2020 P2
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesThis question paper consists of 9 printed pages and 1 blank page. SERANGOON SECONDARY SCHOOL PRELIMINARY EXAMINATION SECONDARY 4 EXPRESS CANDIDATE NAME ( ) CLASS CENTRE NUMBER S INDEX NUMBER COMPUTING 7155/02 Paper 2 (Lab-based) 26 August 2020 2 hours 30 minutes Additional Materials: Electronic version of STBANK.xlsx data file Electronic version of USERNAME.py file Electronic version of FRUIT.py file Insert Quick Reference Glossary Setter(s): READ THESE INSTRUCTIONS FIRST Rename the COMPEXAM folder in the thumb drive to <your name>_<centre number>_<index number>. Retrieve the electronic files from this folder in the thumb drive. Save your work inside this folder in the thumb drive using the file name given. Answer all questions. All tasks must be done in the computer laboratory. You are not allowed to bring in or take any pieces of work or materials on paper or media in any form. Programs are to be written in Python. Save your work using the file name given in the question as and when necessary. The number of marks is given in brackets [ ] at the end of each question or part question. The total number of marks for this paper is 50. For Examiner’s Use 50
2 Quick Reference for Python This quick reference shows some examples of the Python language constructs. The complete Python language is not limited to these examples.
3 1. Identifiers When naming functions, variables and modules, the following rules must be observed: Names should begin with character 'a' - 'z' or 'A' - 'Z' or '_' and followed by alphanumeric characters or '_' Reserved words should not be used. User-defined identifiers are case sensitive. 2. Comments and Documentation Strings # This is a comment """ This is a documentation string over multiple lines """ 3. Input/Output print ("This is a string") s = input ("Instructions to prompt for data entry.") 4. Import import <module> e.g. import math 5. Data Type Data Type Notes int integer float real number Bool boolean str string (immutable) list series of values 6. Assignment Assignment Statement Notes a = 1 integer b = c variable d = "This is a string" string mylist = [1, 2, 3, 5, 5] list or array 7. Arithmetic Operators: Operator Notes + - plus, subtract * / multiply, divide % remainder or modulus ** exponential or power // quotient of floor division 8. Relational Operators: Operator Notes == equality != not equal to > >= greater than, greater than or equal to < <= less than, less than or equal to 9. Boolean Expression Boolean Expression Notes a and b logical and a or b logical or not a logical not 10. Iteration while loop for loop while condition(s): <statement(s) for in range(n): <statement(s)> for record in records: <statement(s)>
4 11. Selection Type 1 Type 2 Type 3 if condition(s): <statement(s)> if condition(s): <statement(s)> else: <statement(s)> if condition(s): <statement(s)> elif condition(s): <statement(s)> else: <statement(s)> 12. Built-in functions (a) Basic functions abs( ) chr( ) float( ) input( ) int( ) ord( ) print( ) range( ) round( ) str( ) format( ) (b) Mathematical functions ceil( ) exp( ) fabs( ) floor( ) log( ) max( ) min( ) pow( ) sqrt( ) trunc( ) format( ) (c) String functions endswith( ) find( ) isalnum( ) isalpha( ) isdigit( ) islower( ) isspace( ) isupper( ) len( ) lower( ) startswith( ) upper( ) 13. Reserved Words Reserved words cannot be used as identifiers. They are part of the syntax of the language. False None True and as assert break class continue def del elif else except finally for from global if import in is lambda nonlocal not
5 Task 1 A bank uses a spreadsheet software to record the amount of loan for each client. You are required to finish setting up the spreadsheet to record the lump sum repayment amount. Open the file STBANK.xlsx. You will see the following data. Save the file as STCLIENTS_<your name>_<centre number>_<index number>.xlsx 1. In cell D20 enter a formula to calculate the median amount of all the loans, rounded to the nearest dollar ($). [2] 2. In cells F4 to F18 enter a formula that uses an appropriate function to indicate the Client Type (S for privileged clients and C for normal clients) by extracting the first letter from the Client ID column. [1] 3. In cells G4 to G18 enter a formula that uses an appropriate function to search for the Interest Rate in the Compound Interest Rate per Year table and use it to complete the Compound Interest Rate column. [2] 4. In cells H4 to H18 enter a formula that uses an appropriate function to calculate the lump sum repayment amount for each client. [2]
6 5. 5 In cells I4 to I18 enter a formula to calculate the discount for each client. Each privileged client is given a discount of 10% of the lump sum repayment amount. Otherwise the discount is 0 (zero). [1] 6. In cells J4 to J18 enter a formula to calculate the Discounted Lump Sum. It is the Lump Sum Repayment less the Discount. [1] 7. 6 In cell I20 enter a formula to count the number of privileged clients. [1] Save and close your file. Task 2 begins on the next page.
7 Task 2 The following program creates a username for a user. It creates the username by appending the name with a series of character ‘0’ (zero) until the length of the username is ten characters long. The name entered must be entered without any space, for example, JohnTan. name = input("Please enter your name: ") size = len(name) if size < 10: username = name + (10-size)*'0' print("Your username is " + username) Open the file USERNAME.py Save the file as MYUSERNAME_<your name>_<centre number>_<index number> 8. Edit the program so that the username is created by appending the name with a series of character ‘9’ until the length of the username is ten characters long. [1] 9. The program needs to validate the length of the name and whether the name contains alphabets only. Save the file as MYUSERNAME2_<your name>_<centre number>_<index number> (a) Edit the program to: ● test whether the user has entered a name of between three to twenty characters containing only alphabets ● output a suitable error message that asks the user to re-enter a name again, and repeat this until the user enters a valid name. [4] (b) Edit the program to: ● ask the user to enter a single character (‘0’ to ‘9’) to be used for appending the name with a series of this character until the length of the username is ten characters long ● output a suitable error message that asks the user to enter a single digit again, and repeat this until the user enters a valid single digit ● use the first ten characters of the name as the username if the name entered contains ten or more characters. [5] Save your program.
8 Task 3 The following program searches a list of fruits sorted in ascending order to check if it is sold in a shop. If the fruit is found in the list, a message is displayed on the screen that states the number of items that are in the list and the position of the fruit in the list. Otherwise, a message is displayed on the screen that states the fruit is not in the list. There are several syntax and logical error(s) in the program. #list of fruits sorted in ascending order fruits_list = ["apple", "grape", "guava", "mango", "orange", "pear"] fruit_to_find = input("Which fruit would you like to search for? " items = length(fruits_list) found = True for i in range(item): if fruits_list[index] == fruit_to_find: print("There are " + str(items) + " fruits in the list, " + fruit_to_find + " is item " + str(i) + " in the list.") found = True else fruits_list[i] < fruit_to_find: break if found = True: print("The fruit is not in the list.") O
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 CPExam Papers · 2024
- BVSS Prelim P1 MSExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices
- SST 2024 Prelim Paper 1 [revised for 2025] Exam Papers · 2024
- SST 2024 Prelim Paper 1 Ans [revised for 2025] Exam Papers · 2024
- [Notes for Computing] Heavily Compressed TextbookNotes/Practices · 2025
- [Notes for Computing] All Definitions/ TermsNotes/Practices · 2025
- (Notes) Heavily Compressed TextbookNotes/Practices · 2025
- See all Computing notes

