2023 NYJC-VJC-TJC P2 Question Paper
Uploaded by Kozak327 · 8 September 2026
Preview
Text from the first pagesThis document consists of 10 printed pages, 1 blank page, and 1 insert. © NYJC 2023 [Turn over NANYANG JUNIOR COLLEGE JC2 PRELIMINARY EXAMINATIONS Higher 2 COMPUTING 9569/02 Paper 2 (Lab-based) 14th August 2023 3 Hours Additional Materials: Removable storage device Electronic version of CPU-PROCESSES.csv data file Electronic version of SPORTS-FACILITIES.txt data file Electronic version of Task4.db data file Insert Quick Reference Guide 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. Approved calculators are allowed. Save each task as it is completed. The use of built-in functions, where appropriate, is allowed for this paper unless stated otherwise. Note that up to 6 marks out of 100 will be awarded for the use of common coding standards for programming style. 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 100.
2 9569/02/2023 Instruction to candidates: Your program code and output for each of Task 1, 2 and 3 should be downloaded in a single .ipynb file. For example, your program code and output for Task 1 should be downloaded as TASK1_<your name>_<centre number>_<index number>.ipynb 1 The freight (shipping) container identification is covered by the ISO 6346 standard . Under ISO 6346, each container is labelled with an 11 -character code (four letters + seven digits) in which the last digit is a “check” digit that is computed from the leftmost 4 letters and 6 digits , according to a fixed rule. For example, in MSKU3881107, the final “7” is the check digit. The check digit is calculated by applying the following algorithm, on the left-most 4 letters and 6 digits of a freight container identification: 1. the four letters are replaced with corresponding numbers. The letters A through Z correspond to the numbers 10 through 38, with all multiples of 11 skipped. 2. the 10 numbers are multiplied by successive powers of two , starting from 2 0 to 29, and added together. 3. take the remainder when dividing by 11, and if the result is 10, it is taken to be zero. For example, given the 4 characters and 6 digits MSKU388110: Step 1: 24 30 21 32 3 8 8 1 1 0 Step 2: 24×20 + 30×21 + 21×22 + 32×23 + 3×24 + 8×25 + 8×26 + 1×27 + 1×28 + 0×29 = 1624 Step 3: 1624 / 11 = 147 remainder 7, hence check digit = 7 For each of the sub -tasks, add a comment statement, at the beginning of the code using the hash symbol ‘#’, to indicate the sub-task the program code belongs to, for example: In [1]: # Task 1.1 Program code Output: Task 1.1 Write a function task1_1(input_value) that returns a string. The function should: validate that the parameter input_value is a string of 4 letters followed by 7 digits return True if the above rule is met, otherwise return False. [5] Task 1.2 Create four tests to test your function. Display the input value used for each test, and its result. Your four input values should be: a string containing only integers a string containing only letters a valid string a string of incorrect length. Test your function with your four input values by calling it using the following statement: print(taskl_l(input_value)) [4]
3 9569/02/2023 [Turn over Task 1.3 Write a function taskl_3(input_value) that returns the calculated check digit. The function should: take in an input_value containing the left-most 4 letters and 6 d igits of the 11 -character code calculate the check digit return the calculated check digit. [3] Task 1.4 A full 11-character freight container identification can be validated by removing the check digit, calculating the check digit from the remaining 10 alphanumeric characters and comparing it to the removed digit. Write a function task1_4(input_value) that returns a Boolean indicating whether the check digit is valid. The function should: validate the parameter input_value by calling your function from Task 1.1 return False if input_value is invalid remove the rightmost digit use your function from Task 1.3 to calculate the check digit from the remaining string return True if the calculated check digit is the same as the check digit in the identification code and False otherwise. [3] Test your function with the following statements: print(task1_4('PONU2079674')) print(task1_4('XONU2079674')) [2] Task 1.5 The rule s pecified by ISO 6346 for computing the check digit is designed so that accidental changes or misreading of a single digit in a code can by identified as it will also change the check digit. Hence, most such errors can be caught easily using the check digit. However, the check digit can sometimes fail to detect a change in the code. Create two test cases such that one test case is different from the other test case by a single character yet both test cases produce the same check digit. Test your function with the following statements: print(task1_4(test_case_1)) print(task1_4(test_case_2)) Both statements should return True. [2] Save your Jupyter notebook for Task 1.
4 9569/02/2023 2 The file SPORTS-FACILITIES.txt contains the total number of bookings for different sports facilities managed by Sport Singapore for the year 2022. Each line contains comma -delimited data that shows the type of facility and the corresponding number of bookings for the facility in 2022 in the following format: Facility,Number of Bookings The task is to read the data from the file SPORTS-FACILITIES.txt, use various sorting algorithms to display a sorted version of the data, and then compare the performance of the sorting algorithms implemented. For each of the sub -tasks, add a comment statement, at the beginning of the code using the hash symbol ‘#’, to indicate the sub-task the program code belongs to, for example: In [1]: # Task 2.1 Program code Output: Task 2.1 One method of sorting data is insertion sort. Write program code to: read the facilities booking data from SPORTS-FACILITIES.txt implement an insertion sort algorithm to sort the data in descending order based on the number of bookings display the sorted data in rows and columns where: o the first column of each row contains data on one type of facility o the second column of each row contains the corresponding number of bookings. [7] Task 2.2 Another method of sorting data is quicksort. Write program code to: read the facilities booking data from SPORTS-FACILITIES.txt implement a quicksort algorithm to sort the data in descending order based on the number of bookings display the sorted data in rows and columns where: o the first column of each row contains data on one type of facility o the second column of each row contains the corresponding number of bookings. [7]
5 9569/02/2023 [Turn over Task 2.3 The sorting algorithms implemented in Task 2.1 and Task 2.2 can be modified to track the number of comparisons made during each sorting process. The number of comparisons can then be used to identify which sorting algorithm is faster for this particular instance. Copy and paste your program codes in Task 2.1 and Task 2.2 into a new cell in your Jupyter Notebook. Modify your program code to: track the number of comparisons made by the sorting algorithm implemented in each task display these numbers determine which sorting process is faster for this instance output an appropriate conclusion. [5] Save your Jupyter notebook for Task 2.
6 9569/02/2023 3 A scheduler is a queue used to ensure that processes in a computer are completed in timely fashion, according to a scheduling algorithm. One such algorithm is the first-come-first-serve algorithm (FCFS), in which each
Content continues in the PDF. Download PDF
Related notes
- 2024 ACJC Computing PromoExam Papers · 2024
- 2023 ACJC Promo QPExam Papers · 2023
- 2022 ACJC Computing Promo Paper 2Exam Papers · 2022
- 2021 ACJC Computing Promo Paper 2Exam Papers · 2021
- 1992 AJC Computing QPExam Papers · 1992
- 2023 YIJC P2 Question PaperExam Papers · 2023
- 2023 YIJC P1 Question PaperExam Papers · 2023
- 2023 RVHS P2 CombinedExam Papers · 2023
- 2023 RI P2 Question PaperExam Papers · 2023
- 2023 RI P1 Question PaperExam Papers · 2023
- 2023 NJC P2 Question PaperExam Papers · 2023
- 2023 JPJC P2 SolutionsExam Papers · 2023
- See all H2 Computing notes

