2021 NASS Computing P2
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesName: Register no: Class: NGEE ANN SECONDARY SCHOOL O PRELIMINARY EXAMINATION COMPUTING 7155/02 Paper 2 (Lab-based) 1 August 2021 2 hr 30 min Additional materials: Electronic version of LIBRARY.xlsx file Electronic version of SANDWICH.py file Electronic version of FACTORIAL.py file Insert Quick Reference Glossary Instructions to Candidates Write your name, register number and class at the top of this page. 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. For Examiner’s Use
2 NAS/2021/PRELIM/4E/COMPUTING(7155/02) Checked by student: _____________________ Date: _________ This document consists of 9 printed pages and 1 blank page. Task 1 A private library uses spreadsheet to keep a record of its books, including generation of book IDs, location of books and their loan status. Open the file LIBRARY.xlsx. You will see the following data. Save the file as LIBRARY_<class>_<index number>_<your name>.xlsx 1 In cell G1, enter an appropriate formula that will automatically generate the current date. [1] 2 The Book ID is generated by using the function CONCATENATION. The Genre, Shelf ID and a random 5 digit number are joined together using CONCATENATION. In cell C25, use the CONCATENATION function together with an appropriate function to generate a Book ID. [1]
3 NAS/2021/PRELIM/4E/COMPUTING(7155/02) 3 Each book loan has a duration of 14 days. An extension on the book loan adds another 7 days. Books that are not loaned out will have a dash ‘-’ in their Loan Expiry Date. In cells G4 to G25, enter a formula that uses appropriate functions to show the Loan Expiry Date. If the book is not on loan, the Loan Expiry Date should show only a dash ‘-’. [2] 4 In cells H4 to H25, enter a formula that uses appropriate functions to show the status of the book. “On-Loan” for books loaned out but not due. “Overdue” for books loaned out and passed the loan expiry date. “available” for books not loaned out. [2] 5 In cells H4 to H25, use a formatting tool to change the colour of the status. Yellow for books On-Loan Red for books Overdue Green for books available [1] 6 The first 5 characters of the Book ID indicates which shelf the books are kept. In cells I4 to I25, enter a formula that uses appropriate functions to show the shelves where the books should be. [2] 7 The Inventory table shows the total number of books that the library has for each Genre. In cells L23 to L28, enter a formula that uses appropriate functions to count the number of books for each genre. Save and close your file. [1]
4 NAS/2021/PRELIM/4E/COMPUTING(7155/02) Task 2 The following program is written for a sandwich bar for customers to place orders and calculate the cost of the sandwiches they have ordered. toppings = ['ham', 'cheese', 'lettuce', 'tomatoes'] top_cost = [1, 0.8, 0.5, 0.5] print("Welcome to All-Health Salad Bar!") print("Please select your toppings below.") ham = int(input("Quantity of ham: ")) cheese = int(input("Quantity of cheese: ")) lettuce = int(input("Quantity of lettuce: ")) tomatoes = int(input("Quantity of tomatoes: ")) total_cost = ham*top_cost[0] + cheese*top_cost[1] + lettuce*top_cost[2] + tomatoes*top_cost[3] print("Total cost: $", total_cost) Open the file SANDWICH.py Save the file as MYSANDWICH_<your name>_<centre number>_<index number>.py 8 Capsicum, a new topping, is added to the list of toppings and will be priced at $0.80 per unit. Edit the program so that the new topping is available for selection. Save your program. [3] 9 Save your program as MYSANDWICH2_<your name>_<centre number>_<index number>.py Each order should be at least $3.
5 NAS/2021/PRELIM/4E/COMPUTING(7155/02) Edit the program so that the user will be continually prompted to re-order if the selection is less than $3. Save your program. [2] 10 Save your program as MYSANDWICH3_<your name>_<centre number>_<index number>.py Customers will get a free drink if the sandwich ordered costs more than $5. Edit the program to inform eligible customers on the free drink. Your program should inform the user with the following message: “You are entitled to a free drink.” Save your program. [2] 11 Save your program as MYSANDWICH4_<your name>_<centre number>_<index number>.py Each topping is given a health score as shown below: Ham: -1 Cheese: -0.5 Lettuce: 3 Tomatoes: 2.5 Capsicum: 3.2 Edit the program to calculate the health score of the purchased sandwich. Orders with a health score of more than 10 will be entitled to $1 discount. Save your program. [3]
6 NAS/2021/PRELIM/4E/COMPUTING(7155/02) Task 3 The program below prompts the user to enter the lower and upper limits of a range of numbers, generates the factorials of all the numbers within the limits (inclusive) and highlights the numbers that are harshad and/or palindromic numbers. The factorial of a number, n, can be written as n! such that n! = n × (n-1) × (n-2)… ×1. For instance, 3! = 3×2×1 = 6 and 9! = 9×8×7×6×5×4×3×2×1 = 362880. It is known that the factorials of all numbers that are smaller than 432 are harshad numbers and that some of these factorials may be palindromic numbers as well. A harshad number is an integer that is divisible by the sum of its digits. The number 18 is a harshad number because the sum of the digits 1 and 8 is 9 (1 + 8 = 9), and 18 is divisible by 9. Other examples of Harshad numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, ... Palindromic numbers refer to numbers that look the same even when the digits in the numbers are reversed. Examples of palindromic numbers include 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, …, 1001, … A sample output of the program is as shown below: Enter the lower limit: 1 Enter the upper limit: 432 1! = 1 is a harshad number. Factorial of 1 is palindromic as well! 2! = 2 is a harshad number. Factorial of 2 is palindromic as well! 3! = 6 is a harshad number. Factorial of 3 is palindromic as well! 4! = 24 is a harshad number. 5! = 120 is a harshad number.
7 NAS/2021/PRELIM/4E/COMPUTING(7155/02) ... ... ... ... ... ... ... ... ... Factorial of 432 is NOT a harshad number. There are several syntax and logic errors in the program. lower = input("Enter the lower limit: ") upper = input("Enter the upper limit: ") for num in range(lower,upper): factorial = 0 factor = num for k in range(factorial): factorial *= factor factor += 1 j = factorial total = 0 i = j while i > 10: total += i/10 i = i//10 total += i if j % total = 0: print(str(num)+"! =", j, "is a harshad number.") if str(j) == str(j)[::1]: print("Factorial of", num, "is palindromic as well!") else print("Factorial of", num, "is NOT a harshad number.") Open the file FACTORIAL.py Save the file as MYFACTORIAL_<your name>_<centre number> <index number>.py
8 NAS/2021/PRELIM/4E/COMPUTING(7155/02) 12 Identify and correct the errors in the program so that it works according to the rules given. Save your program. [10] Task 4 In a printed circuit board manufacturing line, sampling is done to monitor the number of defects in the manufactured products. During sampling, the quality check inspector will check a batc
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

