0% found this document useful (0 votes)
4 views

CWSS 2020 Computing P2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CWSS 2020 Computing P2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

COMMONWEALTH SECONDARY SCHOOL

PRELIMINARY EXAMINATION 2020

COMPUTING
Paper 2 (Practical)

Name: _____________________________________ ( ) Class: ___________

SECONDARY FOUR EXPRESS/NORMAL (ACADEMIC) Wednesday 2 Sep 2020


7155/2 1100 – 1330
2 hour 30 min

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.

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.

Name of setter: Mr Cheong Hock Soan

This paper consists of 6 printed pages including the cover page.


[Turn over
2

Task 1

A delivery company is trying to incentivise its delivery staff to work harder amidst the
spread of the COVID-19 virus. It uses spreadsheet to track the staff’s trips and amount of
money they clocked in their deliveries for a particular week.

Open the file WEEKLY. You will see the following data.

Save the file as GENREPORT_<your name>_<class>_<index number>.xlsx

1 The first letter of the Employee ID states the area that he/she is deployed to work
in. Enter an appropriate function in the Area column to find the area that the
employee is deployed to. [1]

2 Use an appropriate function to search for the Incentive in the Incentive Table,
complete the Incentive column. [2]

3 Enter a formula in the Commission column to calculate the commission that each
staff gets. The commission is calculated by multiplying the incentive to the amount
clocked. [1]

4 Use a conditional statement, to identify those staff who have commission more than
$75.00 and put YES in the Award column. Otherwise, put NO in the Award column.
[2]

5 Use conditional formatting, to identify those staff who have commission less than
$20 by highlighting the cells in the Commission column in red. [2]

6 Use an appropriate function to count the number of staff deployed in each area and
put the number in the Number of Staff column in the Staff Deployment table. [2]

Save and close your file.


3

Task 2

The following program takes in 2 user entries and verifies if the users are Singaporeans by
checking if the first letter of each entry is “S”. If the user is a Singaporean, the program
prints a welcome home message. Otherwise, it prints a welcome to Singapore message.

ID = ''

for i in range(2):
ID = input("Enter ID: ")
if ID[0] == "S":
print("Welcome home!")
else:
print("Welcome to Singapore!")

7 Open the file VERIFY.py

Save the file as MYVERIFY_<your name>_<class>_<index number>.py

Edit the program so that

(i) It takes in 5 entries, [1]

(ii) It prints the same welcome home message if the first letter of the entry is
either “S” or “T”. [2]

(iii) The program counts the total number of Singaporeans in the list. [3]

Save your program.

8 Open the file MYVERIFY.py

Save your file as NUMVERIFY_<your name>_<class>_<index number>.py

Edit the program so that it


• Checks that the length of the ID is 9 characters. Otherwise, it will produce an
error message and keep asking the user to re-enter the ID. [2]
• Works for any number of entries. [2]

Save your program.


4

Task 3

The following program accepts a user-defined string, removes the spaces, and extracts the
characters based on the indices specified by the user.

For example, if the string is “I have a cat” and the indices entered are 2,3,6,8, the program
prints the output of ‘avct’.

There are several syntax errors and logical errors in the program.

string = input("Enter string: ")


index = int(input("Enter the index/indices of characters you wish
to extract in a,b,c format: "))
indx_lst == index.split("")

new_string = ''
final_string = ''

for j in range(string):
if string[j] == '':
break
else:
new_string = new_string + string[j]

for i in range(len(indx_lst)):
indx_lst[i] = indx_lst[i]

for ele in range(indx_lst):


final_string = final_string + new_string[ele]

print("The original sentence is: , string")


print("The index/indices of characters you wish to extract is/are
", indx_lst)
print("The character(s) extracted is/are ", final_string)

Open the file EXTRACT.py

Save the file as LIST_<your name>_<class>_<index number>.py

9 Identify and correct the errors in the program so that it works correctly accordingly
to the rules above. [10]

Save your program.


5

Task 4

You have been asked to write a program to convert the raw marks of four subjects
(English, Mother Tongue, Mathematics and Science) into grades.

A distinction grade (D) is 75% and above.


A credit grade (C) is between 60% (inclusive) and 75% (non-inclusive).
A pass grade (P) is between 50% (inclusive) and 60% (non-inclusive).
A fail grade (F) is below 50%.

The program should allow you to:


• Enter data in the format of a b c d where a, b, c and d are the marks in integer for
English, Mother Tongue, Mathematics and Science. An example is 45 54 66 73.
• Repeat this until the data entry is X.
• Converts all the raw marks into the corresponding grades.
• Calculate the number of Distinctions, Credits, Passes and Failures
• Display this on the screen. Your output must look like this:

Grades for EL MT Math Sci


P C D F
F C C P
D P C C

Number of Distinctions: 2
Number of Credits: 5
Number of Passes: 3
Number of Failures: 2

10 Write your program and test that it works.

You may use the following test data:


54 68 87 45
43 70 69 53
76 54 62 71
x

Save your program as GRADES_<your name>_<class>_<index number>.py [11]

11 Save your program as VERIFYGRD_<your name>_<class>_<index number>.py

Extend your program to validate that:


• The length of each entry is 4
• each grade entry is between 0 and 100 inclusive

Entries are to be re-entered if they fail to meet any of the validation.

Save your program. [3]


6

12 When your program is complete, test it for the following.


• Enter the marks for EL, MT, Math and Sci:
o 45 55 67 78
o -4 56 68 65
o 76 68 12 65
o 60 121 43 88
o 89 54 33 76
o 45 33 98 54 67
o 43 67 80 53
o then X.

Take a screenshot of your test. Save this screenshot as:


TESTGRD_<your name>_<class>_<index number>

Save your files in either .png or .jpg format. [2]

13 Save your program as VARYGRD_<your name>_<class>_<index number>.py

Extend your program such that the user can input and vary the distinction, credit
and passing mark.

Include in your program to validate that the distinction mark to be higher than the
the other two marks, and the credit mark to be higher than the passing mark.

Save your program. [4]

END OF PAPER

You might also like