BVSS 2020 P2
BVSS 2020 P2
CANDIDATE
NAME
CLASS INDEX
NUMBER
COMPUTING 7155/02
Paper 2 (Lab-based) 16 Sep 2020
2 hours 30 minutes
Additional Materials : Electronic version of SALES.xlsx data file
Electronic version of NUMCAT.py file
Electronic version of DATES.py file
Insert Quick Reference Glossary
Write your candidate name, class and number in the spaces at the top of this page.
Write in dark blue or black pen.
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.
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.
50
Setter: Mrs Leong Wee Choo Parent's Signature:__________________
This question paper consists of 9 printed pages.
Task 1
Jane uses an online selling platform to sell women’s bags and uses a spreadsheet to
keep track of her monthly sales.
Open the file SALES.xlsx. You will see the following data.
2
4 In cell D11 enter a formula to count the number of categories that exceed the
sales target. [1]
5 In cell B17 enter a formula to calculate her Projected yearly profit if her
monthly profit is 20% of her total monthly sales. You can assume that her
sales per month remains fairly constant. [2]
6 She took up a loan of $30000 to start her business. The bank charges her
3.88% per annum compounded monthly for a period of 3 years.
In cell B19 enter an appropriate function to calculate the amount she needs
to pay after 3 years. [2]
7 In cell B21 enter a conditional statement to determine if she is able to pay the
bank based on her projected yearly profit after 3 years by putting able or
unable. [1]
3
Task 2
The following program allows 10 integers to be input. The numbers which must be
within 1 to 100 inclusive are then printed as Low, Medium or High.
8 (a) Edit the program so that it will accept any number of input. The
program will end only when the user enters 0. You can assume that
only digits will be entered. [2]
● test whether the user has entered a number in the correct range
● output a suitable error message that asks the user to enter the
number again, and repeat this until the user enters a valid
number. [2]
(c) Edit the program to print how many numbers were classified as “Low”,
“Medium” or “High”, after the user entered 0.
4
9 Save your program as NUMCATV2_<your name>_<index number>.py
As a result of this change, numbers that are greater than 70 but smaller than
or equal to upper_limit will be categorized as High.
Edit your program so that it works correctly with this new boundary. [3]
5
Task 3
The following program reads in 3 numbers, each a part of a date and the program
will print the date in the format dd Mmm yyyy.
For example, user enters 9, 4, 1991. The program will print 09 Apr 1991.
● there are 30 days in the months of April, June, September and November
● if day entered is less than 10, the output will have a ‘0’ prepended
● there is a space between the day, month and year
● year should be between 1900 and 2200 inclusive
This program assumes non-leap year and all inputs are digits.
month_abbr = ['Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec']
# validate day #
while day < 1 or day > 30:
day = int(input("Invalid day. Re-enter the day: "))
#validate month
while month < 1 and month > 12:
month = int(input("Invalid month. Re-enter the month: "))
# validate year
while year > 1900 or year > 2200:
year = int(input("Invalid year. Re-enter the year: "))
6
Open the file DATES.py
7
Task 4
You have been asked to create a code-breaking game for two players.
● allow player 1 to input a 4-character code denoted by the first letter of these
colours : Red, Blue, Green, Yellow, Purple, Orange. The code will be
converted to upper case by the program after entry. The program must ask
for another code each time the player enters a code that is not 4-character
long or comprises of letters not from the first letter of the above 6 colours.
● allow player 2 to enter a 4-character capitalized code. Player 2 will have 4
guesses to correctly guess the code input by player 1. You do not need to
validate the input for player 2.
● Output “Code broken!” when player 2 inputs the same code as player 1 and
the game must end.
● Output “Incorrect” when player 2 does not input the same code as player 1.
● Output “Game over!” when player 2 has entered four incorrect codes.
8
13 Save your program as CODEBREAKER2_<your name>_<index number>.py