SST 2020 S4 Computing P2
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesSECONDARY 4 PRELIM EXAMINATION COMPUTING Paper 2 Practical (Lab-based) 7155/02 14 August 2020 (Friday) 2 hours 30 minutes CANDIDATE NAME CLASS INDEX NUMBER Additional Materials: Electronic version of CAR.XLSX data file Electronic version of PASSWORD.PY file Electronic version of SHN.PY file Insert Quick Reference Glossary READ THESE INSTRUCTIONS FIRST Answer all questions. All tasks must be done in the computer laboratory. You are not allowed to bring in or take out any pieces of work or materials on paper or electronic media or in any other 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. This document consists of 6 printed pages. For Examiner’s Use 1 1 2 1 3 2 4 2 5 2 6 2 7 1 8 2 9 3 10 4 11 10 12 12 13 5 14 3 Total /50
Page 2 of 7 Task 1 A car dealer uses a spreadsheet software to record the list of customers who recently bought a car from them, and the type of loans they made. You are required to finish setting up the spreadsheet. For consistency, you are also required to display all results as positive numbers. Open the file CAR.xlsx. You will see the following data. Save your file as CAR_<your name>_<index number>.xlsx 1. In cell B19, enter a formula to calculate the total price of the vehicles sold. [1] 2. In cell B20, enter a formula to calculate the range of prices of vehicles sold. [1] 3. The loan amount is the amount of money for the car not paid in the down payment. In cells E3 to E17, enter a formula that uses an appropriate function to calculate the loan amount each customer has to take to complete the Loan Amount column. [2] 4. In cells G3 to G17, enter a formula that uses an appropriate function to search for the Interest Rate Per Annum (P.A.) in the Rate table and use it to complete the Interest Rate (P.A.) column. [2] 5. In cells H3 to H17, enter a formula to calculate the monthly instalment each customer has to pay and use it to complete the Monthly Instalment column. [2] 6. A reminder will be sent to customers who have taken more than or equal to $28 000 in loans and whose loan terms are 5 years or less. In cells I3 to I17, enter a conditional statement to identify such customers and put Yes in the Reminder column. Otherwise put No in the cell. [2] Save and close your file.
Page 3 of 7 [Turn over
Page 4 of 7 Task 2 The following program simulates a scenario that a user sets a password for the first time. After that, the system allows the user to have three attempts in logging into the system with the correct password. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #User sets password and tries to log into a system password = input("Please set password: ") print("Your password is : ", password) count = 3 hit = False while count > 0 and hit == False: print("Please log into the system.") print("You have {} attempt(s) left.".format(count)) user_input = input("Please enter the password: ") if user_input == password: print("You have successfully logged into the system.") hit = True else: print("You did not enter the correct password.") count -= 1 if count == 0: print("You are locked out of the system.") Open the file PASSWORD.py Save the file as PASSWORD_<your name>_<index number>.py Edit the program so that it: 7. Allows up to 4 password attempts when logging into the system. [1] 8. Prints out the reversed form of the password (e.g. “ABCD” is printed as “DCBA”) right after a valid password has been set. [2] 9. Ensures that the password consists of at least 8 characters. Otherwise, the program should inform the user about the input requirements and ask for re-entry of the input. [3] 10. Ensures that the set password consists of at least 1 upper case alphabet (‘A’ to ‘Z’). Otherwise, the program should inform the user about the input requirements and ask for re-entry of the input. [4]
Page 5 of 7 [Turn over Task 3 The following program takes in a date, DS, as an input string with the format "DD MM YYYY". It then adds 14 days to DS and outputs the new date. The program takes into consideration the leap years. A leap year is exactly divisible by four except for years that are exactly divisible by 100. However, these centurial years are leap years if they are exactly divisible by 400. There are several logical and syntax errors in the program. #Input DS = input("DD MM YYYY:").split() MM, Yr = int(DS[1], DS[2]) #Check if it is Leap year leap_yr = false if (Yr % 4) == 0: if (Yr % 100) == 0: if (Yr % 400) == 0: leap_yr = True else: leap_yr = True #Check for total days of the month max_day = 31 if MM in [4, 6, 8, 11]: max_day = 30 elif MM = 2: max_day = 28 newDD, newMM, newYr = int(DS[0])+14, MM, Yr #Check for day, month, year value overflow if newDD > max_day: newDD = newDD MOD max_day newMM += 1 if newMM > 12: newMM = 1 newYr -= 1 #Output result print("+14 days\nDD: {} MM: {} YYYY: ".format(newDD,newMM,newYr)) Open the file SHN.py Save the file as MYSHN_<your name>_<index no>.py 11. Identify and correct the errors in the program Save your program. [10]
Page 6 of 7 Task 4 Due to the Circuit Breaker implementation, Keanu is unable to meet up regularly with his classmates to play their favourite tabletop role-playing game (TRPG). The TRPG uses six types of different sided dice for different occasions. There are four-sided (d4), six-sided (d6), eight-sided (d8), ten-sided (d10), twelve-sided (d12) and twenty-sided (d20) dice. The dice rolling is split into two main types: a to-hit roll and a damage roll. I. A to-hit roll is done using a single twenty-sided die plus a value B. If the roll is equal to or greater than a target number (Tn), then it is considered a success roll; otherwise it is a failed roll. If this roll is successful, a damage roll will be required. II. A damage roll is done using N number of X-sided dice plus a value C. For example 2d6 +10, will mean rolling two six-sided dice, summing up the value and then adding 10. Such rolls can be generalised as NdX + C. You have been asked to write a program to do the following: • Output the message "Enter values for B, Tn, N, X, and C, each separated by a space:" • Allow user to input a string with the following format "B Tn N X C" where 0 ≤ B, C ≤ 10 5 ≤ Tn ≤ 30 1 ≤ N ≤ 20 X ∈ {4, 6, 8, 10, 12, 20 } • Output "Invalid input" if any of B, Tn, N, X or C are not within the valid range, and ask for re-entry. • Output the message "1d20 + B, Target Number: Tn", where B and Tn are the input values. • Output a single integer, P, where P is the sum of B and a randomly generated value between 1 and 20. • Output "Fail" if P is less than Tn, then end the program. Otherwise output "Pass". • Output "Damage: NdX + C", where N, X and C are the input values. • Output N numbers of randomly generated values between 1 to X in a single line. • Output "Total: S", where S is the sum of the N random nu
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

