2021 TSS Computing P2
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesTask 1 A student is collating orders for her class for lunch during Teacher’s Day celebration: Each student has ordered at least 2 items and up to 3 items from the menu. Each menu item has a unique ID code. For mains, the ID begins with an ‘M’. For sides, the ID begins with an ‘S”. For drinks and dessert, the ID begins with a ‘D’. You are required to finish setting up the spreadsheet to tabulate the orders and total cost. Open the file TASK1.xlsx. You will see the following data. Save the file as TASK1_<your name>_<class>_<index number>.xlsx For the following questions, where appropriate , all currency values should be shown in 2 decimal places, e.g. $1.00. 1 In cell s D4 to D28 , use an appropriate function to determine the corresponding prices of each order item in cells C4 to C28 from the ‘Summary’ table on the right. Likewise, complete cells F4 to F28 with prices of order items in cells E4 to E28. [2] 2 In cells H4 to H28, use an appropriate formula to determine the corresponding prices of each order item in cells G4 to G28 from the ‘Summary’ table on the right. If the student has not ordered a third item, then the price should be shown as $0.00. [1] 3 If a student has ordered a main, a side and a drink or dessert, then it is considered a set meal and the student will be entitled to a 10% discount.
2 In cells I4 to I28, use an appropriate function to determine the discount amount each student is entitled to, in dollars. [2] 4 In cells J4 to J28, use an appropriate formula to determine the total cost that each student needs to pay for their lunch, taking into consideration the discount that they are each entitled to. [1] 5 In cell s O4 to O30 , use an appropriate function to determine the total quantity ordered by the class for each menu item. [2] 6 In cell J30, use an appropriate function to determine the average payment to be made by each student. [1] 7 In cells J4 to J28, apply conditional formatting to underline the values that are equal to or greater than 120% of the average value found in Question 6. [1]
3 Task 2 The following program helps the user to solve a quadratic equation, ax2 + bx + c = 0, where the values for a, b and c are integers input by the user. a = int(input("Enter value of 'a': ")) b = int(input("Enter value of 'b': ")) c = int(input("Enter value of 'c': ")) sol1 = (-b+(b**2-4*a*c)**0.5)/(2*a) sol2 = (-b-(b**2-4*a*c)**0.5)/(2*a) print(sol1, sol2) Open the file TASK2.py Save the file as TASK2_Q8_<your name>_<class>_<index number>.py 8 Edit the program so that it: (a) Outputs the statement "The solutions to this quadratic equation are X and Y." at the end of the program, where X and Y represents the value of the two solutions. [1] (b) Checks whether the two solutions are the same. If they are, the program should output the statement "The only solution to this quadratic equation is X." at the end instead. [2] (c) It checks whether the determinant, b2 - 4ac, is less than zero. If it is less than zero, the program should output the statement "There are no real solutions to this quadratic equation." without performing any further calculations. [2] Save your program.
4 9 Save your program as TASK2_Q9_<your name>_<class>_<index number>.py Edit the program so that it: (a) Asks the user for confirmation after a, b and c values are input. For example, "The quadratic equation is Ax^2 + Bx + C = 0, correct? (Y/N):" where A, B and C represents the a, b and c values keyed in by the user. If the user inputs "N", then the program should ask to re-enter the values again until the user confirms with a "Y". [2] (b) When asking the user for confirmation in part (a), the quadratic equation displayed is simplified. The two examples below describe how it should be simplified. When values of a and b are 1 or -1, the program should omit the “1” character in the equation. For example: "-1x^2 + 1x + 2 = 0" is simplified as "-x^2 + x + 2 = 0". When values of b and c are negative, the program should omit the “+” character in the equation. For example: "2x^2 + -3x + -4 = 0" is simplified as "2x^2 - 3x - 4 = 0". [3] Save your program.
5 Task 3 The following program provides information about the COVID-19 vaccination programme in Singapore. The program does the following: Allows the user to input their year of birth and whether they have drug allergy. Informs the user the type of vaccine they are eligible for and whether an appointment is required, based on the table below: Age (Years) No Drug Allergies With Drug Allergies <12 Not Eligible Not Eligible 12 - 17 Pfizer-BioNTech (With appointment) Not Eligible 18 - 59 Pfizer-BioNTech (With appointment) Moderna (Without appointment) Novavax (With appointment) > 59 Pfizer-BioNTech (Without appointment) Moderna (Without appointment) Novavax (Without appointment) There are several syntax errors and logical errors in this program: age = int(input("Enter your year of birth: ")) - 2021 allergy = int(input("Do you have any drug allergies? (Y/N): ")) eligible_with_appt = "" eligible_without_appt = "" if age >= 59: if allergy == "N": eligible_without_appt += ["Pfizer-BioNTech"] eligible_without_appt += ["Moderna"] else: eligible_without_appt += ["Novavax"] if age >= 18: if allergy == "N": eligible_with_appt += ["Moderna"] eligible_without_appt += ["Pfizer-BioNTech"] else: eligible_with_appt += ["Novavax"] if age > 12: if allergy == "Y": eligible_with_appt += ["Pfizer-BioNTech"] if len(eligible_without_appt) ==0 or len(eligible_with_appt) ==0: print("You are not eligible for any vaccination.") else: print("You are eligible for:") for vaccine in eligible_without_appt: print("- {} vaccine without appointment.".format(vaccine)) for vaccine in eligible_with_appt: print("- {} vaccine with an appointment.".format(vaccine)) Open the file TASK3.py Save the file as TASK3_<your name>_<class>_<index number>.py 10 Identify and correct the errors in the program so that it works according to the description given. [10] Save your program.
6 Task 4 You have been asked to create a program for a simple calculator that performs the four basic mathematical operations, +, -, × and ÷. The program should allow you to: Enter a mathematical expression represented by two positive real numbers separated by a basic operator between them. The multiplication operator (×) is represented by "*" and the division operator (÷) is represented by "/", for example, "1.2*3.3" and "5/3" Output the evaluated result, beginning with an equal sign (=), for example "=3.96". You may use the function format(float,'.10g') to limit the result to 10 significant digits. Asks the user to input the next mathematical expression to be evaluated. This program should repeat until the user enters an empty input, i.e. "". Example: Enter an expression: 0.2+0.3 =0.5 Enter an expression: 9-4 =5 Enter an expression: 1.5*8 =12 Enter an expression: 12/4.0 =3 Enter an expression: >>> 11 Write your program and test that it works. [5] Save your program as TASK4_Q11 _<your name>_<class>_<index number>.py 12 When your program is complete, use the following test data: 0.1+0.2 3-2 0.5*6 9/3.0 End the program with an empty input, i.e. "". Take a screenshot of the outputs displayed on the screen and save as: [2] TASK4_Q12 _<your name>_<class>_<index number> Save your files in either .png or .jpg format.
7 13 Save your program as TASK4_Q13 _<your name>_<class>_<index number>.py Extend
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

