2023 RVHS P2 Combined
Uploaded by Kozak327 · 8 September 2026
Preview
Text from the first pages1 9569/02/Prelim/2023 RIVER VALLEY HIGH SCHOOL General Certificate of Education Advanced Level Higher 2 Preliminary Examination COMPUTING Paper 2 (Lab-based) 9569/02 15 AUG 2023 3 hours Additional Materials: Electronic version of: Animals_lst.txt Task2a.txt Task2b.txt Teachers.csv GUARDIAN.csv RESULT.csv STUDENT.csv Insert Quick Reference Guide READ THESE INSTRUCTIONS FIRST Answer all questions. All tasks must be done in 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. 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. This document consists of 12 printed pages.
2 9569/02/Prelim/2023 Instruction to candidates: Your program code and output for each of Task 1 to 3 should be saved in a single .ipynb file using Jupyter Notebook. For example, your program code and output for Task 1 should be downloaded as TASK1_<your name>__<index number>.ipynb Make sure that each of your .ipynb files shows the required output in Jupyter Notebook. 1 Name your Jupyter Notebook as: TASK1_<your name>_<centre number>_<index number>.ipynb The task is to implement the class Animal and its inherited classes using OOP based on the information described below. Class Animal Attributes name <string> It stores the name of the animal mass <integer> It stores the mass of the animal in grams. volume <integer> It stores the volume of the animal in cm3 age <float> It stores the age of the animal in year to 1 decimal place. Functions getters The getter functions for all the attributes of the class Animal isSick() This function returns True if the density of the animal is less than 0.8 and False otherwise. __str__() This function returns a string that shows all its attributes. For example: “Name: D01 Age: 0.5 Mass: 1007 volume: 1009” Class WarmBloodAnimal (inherits class Animal) Additional attributes bodyTemp <float> It stores the body temperature of the animal to 1 decimal place. Class ColdBloodAnimal (inherits class Animal) Additional attributes isPoisonous <Boolean> True means the animal is poisonous and False otherwise. getIsPoisonous The getter function for isPoisonous
3 9569/02/Prelim/2023 Class Dog (inherits class WarmBloodAnimal) Attributes hasOwner <Boolean> True means the Dog has owner and False otherwise Functions hasFever() This function returns True if bodyTemp is higher than 39.0 and False otherwise. isSick() This function behaves the same way as that of its parent class. On top of it, it returns True if the Dog has fever. isYoung() This function returns True if the age of the Dog is less than 1.0 and False otherwise __str__() This function returns a string that shows its class and all its attributes and indicates if it is sick/well and if it is young/adult. Class Goose (inherits class WarmBloodAnimal) Functions hasFever() This function returns True if bodyTemp is higher than 43.0 and False otherwise. isSick() This function behaves the same way as that of its parent class. On top of it, it also returns True if the Goose has fever. isYoung() This function returns True if the age of the Goose is less than 0.5 and False otherwise __str__() This function returns a string that shows its class and all its attributes and indicates if it is sick/well and if it is young/adult. Class Frog (inherits class ColdBloodAnimal) Functions isYoung() This function returns True if the age of the Frog is less than 0.3 and False otherwise. __str__() This function returns a string that shows its class and all its attributes and indicates if it is sick/well and if it is young/adult. Class Snake (inherits class ColdBloodAnimal) Attributes length <float> It stores the length of the snake in m and to 1 dp. Functions isSick() This function first calculates the normal mass of a Snake based on its length. If the mass of the Snake is less than 0.8 of the calculated mass, it returns True. Otherwise, it returns False. The formulae to calculate the mass of the snake in g based on its length in m is 0.00035 x (snake’s length x 100)3. isYoung() This function returns True if the age of the Snake is less than 0.5 and False otherwise __str__() This function returns a string that shows its class and all its attributes and indicates if it is sick/well and if it is young/adult.
4 9569/02/Prelim/2023 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 program code to declare all the classes described above. [18] Task 1.2 Write program code to: • create 8 instances of the following: o 1 Young Well Dog that is not owned with name "D01" o 1 Adult Sick Dog that is not owned with name "D02" o 1 Young Well Goose with name "G01" o 1 Adult Sick Goose with name "G02" o 1 Young Well non-poisonous Frog with name "F01" o 1 Adult Sick poisonous Frog with name “F02” o 1 Young 1m long Well non-poisonous Snake with name “S01” o 1 Adult 4m long Sick poisonous Snake with name “S02" • Add all the 8 instances in a list. Iterate it and output all of them using the __str__() method. [5] Task 1.3 Write a function, task1_3() to: • read the file “Animals_lst.txt” • process its content and create the appropriate instances for each animal • add all the instances in a Python list and return it. The format of the information in “Animals_lst.txt” is as follow: • If it is a dog, Dog, name, mass, volume, age, body_temperature, hasOwner • If it is a goose, Goose, name, mass, volume, age, body_temperature • If it is a frog, Frog, name, mass, volume, age, isPoisonous • If it is a snake, Snake, name, mass, volume, age, isPoisonous, length [3]
5 9569/02/Prelim/2023 Task 1.4 Write a function, task1_4(a_list, animal_type) to: • iterate a_list which contains different animal instances • collect 4 pieces of information based on animal_type (see example below) • output it in a table in the same format as show below. For example, >>> a_list = task1_3() >>> task1_4(a_list, Dog) ------------------------------- | Dog | Well | Sick | |-----------------------------| | Young | 8 | 4 | |-----------------------------| | Adult | 6 | 2 | ------------------------------- [3] Test your program with the following test data: a_list = task1_3() task1_4(a_list, Dog) task1_4(a_list, Goose) task1_4(a_list, Frog) task1_4(a_list, Snake) [1] Task 1.5 Write a function, task1_5(a_list, animal_type) to: • find all the young animal of animal_type that has its volume larger than that of the smallest adult animal of the same animal type • return the name of this group of young animals in a list. [4] Task 1.6 Write a function, task1_6(a_list) to: • filter out all the Cold Blood Animal in a_list • perform merge sort on them according to their mass in ascending order • return only the names of the cold blood animals in a list sorted according to their mass in ascending order. [4] Test your program with the following test data: a_list = task1_3() task1_6(a_list) [1]
6 9569/02/Prelim/2023 2 Name your Jupyter Notebook as: TASK2_<your name>_<centre number>_<index number>.ipynb The task is to implement the class Node and class SortedLinkedList using the free space concept. Class Node Attributes data <string> It stores the data in the node. next_ptr <integer> It stores the index
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 RI P2 Question PaperExam Papers · 2023
- 2023 RI P1 Question PaperExam Papers · 2023
- 2023 NYJC-VJC-TJC P2 Question PaperExam Papers · 2023
- 2023 NJC P2 Question PaperExam Papers · 2023
- 2023 JPJC P2 SolutionsExam Papers · 2023
- See all H2 Computing notes

