SRSS 2020 P2
SRSS 2020 P2
PRELIMINARY EXAMINATION
SECONDARY 4 EXPRESS
CANDIDATE
( ) CLASS
NAME
CENTRE INDEX
S
NUMBER NUMBER
COMPUTING 7155/02
Paper 2 (Lab-based) 26 August 2020
2 hours 30 minutes
Setter(s):
Rename the COMPEXAM folder in the thumb drive to <your name>_<centre number>_<index number>.
Retrieve the electronic files from this folder in the thumb drive.
Save your work inside this folder in the thumb drive using the file name given.
All tasks must be done in the computer laboratory. You are not allowed to bring in or take any pieces of
work or materials on paper or media in any 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
2
1. Identifiers 6. Assignment
Operator Notes
2. Comments and Documentation Strings + - plus, subtract
* / multiply, divide
# This is a comment % remainder or modulus
"""
** exponential or power
This is a documentation string // quotient of floor division
over multiple lines
""" 8. Relational Operators:
Operator Notes
3. Input/Output == equality
!= not equal to
print ("This is a string") > >= greater than, greater than
or equal to
s = input ("Instructions to prompt for data entry.")
< <= less than, less than or equal
to
4. Import
9. Boolean Expression
import <module>
Boolean Notes
e.g. import math Expression
a and b logical and
a or b logical or
5. Data Type
not a logical not
Data Type Notes
int integer 10. Iteration
float real number
Bool boolean while loop for loop
str string (immutable) while condition(s): for in range(n):
list series of values <statement(s) <statement(s)>
for record in records:
<statement(s)>
3
11. Selection
Reserved words cannot be used as identifiers. They are part of the syntax of the language.
4
Task 1
A bank uses a spreadsheet software to record the amount of loan for each client. You
are required to finish setting up the spreadsheet to record the lump sum repayment
amount.
Open the file STBANK.xlsx. You will see the following data.
1. In cell D20 enter a formula to calculate the median amount of all the loans, rounded to [2]
the nearest dollar ($).
2. In cells F4 to F18 enter a formula that uses an appropriate function to indicate the Client [1]
Type (S for privileged clients and C for normal clients) by extracting the first letter from
the Client ID column.
3. In cells G4 to G18 enter a formula that uses an appropriate function to search for the [2]
Interest Rate in the Compound Interest Rate per Year table and use it to complete
the Compound Interest Rate column.
4. In cells H4 to H18 enter a formula that uses an appropriate function to calculate the [2]
lump sum repayment amount for each client.
5
5. 5In cells I4 to I18 enter a formula to calculate the discount for each client. Each privileged [1]
client is given a discount of 10% of the lump sum repayment amount. Otherwise the
discount is 0 (zero).
6. In cells J4 to J18 enter a formula to calculate the Discounted Lump Sum. It is the [1]
Lump Sum Repayment less the Discount.
7. 6In cell I20 enter a formula to count the number of privileged clients. [1]
6
Task 2
The following program creates a username for a user. It creates the username by appending
the name with a series of character ‘0’ (zero) until the length of the username is ten
characters long.
The name entered must be entered without any space, for example, JohnTan.
size = len(name)
8. Edit the program so that the username is created by appending the name with a series [1]
of character ‘9’ until the length of the username is ten characters long.
9. The program needs to validate the length of the name and whether the name contains
alphabets only.
7
Task 3
The following program searches a list of fruits sorted in ascending order to check if it is sold
in a shop.
If the fruit is found in the list, a message is displayed on the screen that states the number
of items that are in the list and the position of the fruit in the list. Otherwise, a message is
displayed on the screen that states the fruit is not in the list.
found = True
for i in range(item):
if fruits_list[index] == fruit_to_find:
print("There are " + str(items) + " fruits in the list, " +
fruit_to_find + " is item " + str(i) +
" in the list.")
found = True
if found = True:
print("The fruit is not in the list.")
8
Task 4
You have been asked to create a program to generate a check digit.
● Allow a user to enter a twelve-digit number. The program must ask for another
twelve-digit number each time the user enters an input that is not a twelve-digit
number.
● Each digit, starting from left to right, is alternately multiplied by the weights 1 or 3
and the results are sum up together.
Example of a twelve-digit : 978030640615
9×1 + 7×3 + 8×1 + 0×3 + 3×1 + 0×3 + 6×1 + 4×3 + 0×1 + 6×3 + 1×1 + 5×3 = 93
● The sum from the previous step is divided by ten to get the remainder.
93 / 10 = 9 remainder 3
● Subtract the remainder from ten to obtain the check digit.
10 – 3 = 7
So 7 is the check digit.
● Display this on the screen. Your output must look like this:
Extend your program to allow the user to input the weights for both the odd-numbered
and even-numbered digit to be used for the calculation of the check digit.
Extend your program to allow the user to enter either a twelve-digit or thirteen-digit
number. When the user enters a thirteen-digit number, the right most digit is the check
digit and a suitable message must then be output to indicate whether this check digit
is valid or not.
END OF PAPER
10