2021 BLSS Computing P2
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesBLS/PRELIM/2021/4E/COMP/7155/02 BOON LAY SECONDARY SCHOOL PRELIMINARY EXAMINATION 2021 Name CCA Subject : COMPUTING Paper No : 2 (LAB-BASED) Subject Code : 7155/02 Level : SECONDARY FOUR EXPRESS Date/Day : 15th SEPTEMBER 2021 / WEDNESDAY Time : 0815 – 1045 Duration : 2 HOURS 30 MINUTES Additional Materials: Electronic version of Total Residents (2010-2019).xlsx Electronic version of HANGMAN.py Electronic version of NUMBER.py Electronic version of Insert Quick Reference Glossary READ THESE INSTRUCTIONS FIRST Before you start your exam, check that you have received the correct paper and the number of printed pages are correct. Write your name, index number, and CCA in the spaces 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. This document consists of 6 printed pages.
2 BLS/PRELIM/2021/4E/COMP/7155/02 Task 1 The figure below shows the total residents in Singapore between 2010 and 2019. Open the file Total Residents (2010-2019).xlsx Save the file as Total Residents (2010-2019)_INDEX_NAME.xlsx. 1 In cell M24, use vlookup() to find out the total number of residents in Singapore between 30-34 years old in 2016. [2] 2 In cell M22, use hlookup() to find out the total number of residents in Singapore between 5-9 years old in 2011. [2] 3 In cells C19 to L19, calculate the number of residents who are between the ages of 0 and 19 years old for each year. [2] 4 In cells N4 to N17, calculate the average number of residents for each age group between 2010 and 2019 inclusive. [2] 5 In cells C4 to L4, use conditional formatting to highlight years where the total residents between 0 and 4 years old was below the average calculated in cell N4. [2] Save and close your file.
3 BLS/PRELIM/2021/4E/COMP/7155/02 Task 2 A hangman game is played by allowing the user to guess a word, one character at a time. A version of the game is implemented in the code shown below. import random word_list = ['cup','milk','car','bus','bird','song'] chosen_word = word_list[random.randint(0,len(word_list))] #print(chosen_word) grid = [] for i in range(len(chosen_word)): grid.append("_") while "_" in grid: print(grid) user = input("What's your guess? : ") if user in chosen_word: print("{} is in the word!".format(user)) grid[chosen_word.index(user)] = user else: print("not found") print("try again") print() print("Congratulations!") Open the file HANGMAN.py Save the file as HANGMAN_INDEX_NAME.py 6 Edit the program so that it: (a) Outputs a welcome message when the program is run. [1] (b) Counts the number of rounds the player took to guess the word and output the number when the game ends. [4] (c) Converts inputs to the lower case. [2] (d) Tracks and outputs the guesses that have been entered every round. [3] Save your program.
4 BLS/PRELIM/2021/4E/COMP/7155/02 Task 3 The code below shows the Python code for a number guessing game. The game follows the following rules: • The secret number is between 1 and 999, inclusive. • Only numerical inputs are accepted. • If the player’s guess is higher, the program will output that the guess is higher. • If the player’s guess is lower, the program will output that the guess is lower. • The game ends when the user guesses the secret number correctly. import randomn NUM = random.randint0,999) user = -1 while user != NUM: while True: user = input ("key in a number: ") if user.isdigit() user = user break else: print("numbers only.) if user = NUM: print("You've got it!") elif user <= NUM: print("Your guess is lower!") elif user < NUM: print("Your guess is higher!") Open the file NUMBER.py Save the file as NUMBER_INDEX_NAME.py 7 Identify and correct the errors in the program so that it works according to the rules given. Save your program. [10]
5 BLS/PRELIM/2021/4E/COMP/7155/02 Task 4 A contact list is used to store the name, contact number, age and gender of a group of friends. 8 Write a program that allows the user to key in the following information while adhering to the restrictions. Information Restrictions Name Nil Contact Number Must contain 8 digits. Age Nil Gender “M” or “F” For each contact, all 4 pieces of information must be keyed in. After keying in all 4 pieces of information, output the information for each contact as shown below. Save the file as CLIST_INDEX_NAME.py [10] 9 When your program is complete, key in the following information and take a screen shot of each entry. • Test 01 Filename: Test_01_INDEX_NAME Name Tiny Tots Contact Number 98765432 Age 5 Gender F • Test 02 Filename: Test_02_INDEX_NAME Name Looney Tunes Contact Number 1234567, 12345678 Age 9 Gender X, M Save your files either in .png or .jpg format. [2]
6 BLS/PRELIM/2021/4E/COMP/7155/02 10 Extend your code in Q8 to: • Capitalise the first letter of the name • Restrict the age to between 0 and 150, inclusive • Check that the first digit of the phone number is either a 6, 8 or 9 Save the file as CLIST2_INDEX_NAME.py [6] 11 Modify your code to output the name of the youngest person in the contact list. You may use the following data to test your program: Name Tiny Tots Contact Number 98765432 Age 5 Gender F Name Looney Tunes Contact Number 12345678 Age 9 Gender M Name Elderberry Contact Number 61234757 Age 99 Gender M Save the file as CLIST3_INDEX_NAME.py [2]
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

