0% found this document useful (0 votes)
17 views8 pages

JYSS 2020 Computing P2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views8 pages

JYSS 2020 Computing P2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

JUNYUAN SECONDARY SCHOOL

PRELIMINARY EXAMINATION 2020


SECONDARY FOUR EXPRESS

CANDIDATE NAME

CLASS INDEX NUMBER

COMPUTING 7155/02
Paper 2 (Practical) 1 Sep 2020
2 hours 30 minutes
Additional Materials: 1 x Thumb Drive
Electronic version of TASK1.xls file
Electronic version of TASK2.py file
Electronic version of TASK3.py file
Insert Quick Reference Glossary

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.

For Examiner’s Use

Task 1 10
Task 2 10
Task 3 10
Task 4 20
Total 50

This document consists of 7 printed pages, 1 blank page and 2 pages of Python Quick Reference.
[Turn over
2

Task 1

Thorntastic Durian Imports uses a spreadsheet to track its durian sales records. You are
required to finish setting up the spreadsheet to record the monthly sales data for the month of
March.

Open the file TASK1.xlsx. You will see the following data.

Some of the rows in the file have been hidden in the display below.

Save the file as DURIAN_<Class>_<Index>_<Name>.xlsx.


3

1 Figure 1 below shows an example of an Order Code.

The Order Code is made up of 13 characters and the breakdown of the code is shown
below.

Separator Separator

I M - M S W 1 2 4 5 - M Y

Import Durian Order Country


Status Code Number Code

Figure 1 : Sample of Order Code

For the cell range C7:C35, use an appropriate function to extract the Durian
Code from the Order Code. [2]

2 Use an appropriate function to search for the Cost per KG in the Durian Price
table given and use it to complete the Total Sales before Discount ($) column.
The sales must take into consideration the Quantity Ordered (KG). [3]

3 For the cell range F7:F35, use an appropriate function to extract the Country
Code from the Order Code. [1]

4 Use a conditional statement to identify orders that qualify for a discount or incur
a surcharge. If the country code for the order is SG or MY, it qualifies for a
Discount. If the country code for the order is OT, it incurs a Surcharge. [2]

5 Orders that qualify for a discount are given 12% off the total sales while orders
that incur a surcharge have to pay 20% more than their total sales.
Use a conditional statement to calculate the actual sale of each order in the
Actual Sales ($) column. [2]

Save your work.

4E Computing P2 2020 Prelim [Turn over


4

Task 2

The following program accepts the age in years for five employees and prints out the oldest
age.

oldest = 0
counter = 0

while counter < 5:


age = int(input("Enter an employee’s age in years: "))
if age > oldest:
oldest = age
counter += 1

print("The oldest employee is ", oldest, "years old.")

Open the file TASK2.py

Save the file as VARAGE1_<Class>_<Index>_<Name>.py

6 Edit the program so that it:


(a) Accepts the age of 10 employees. [1]

(b) Prints out the oldest age as well as the average age of all employees, rounded
down to a whole number. [4]

(c) Tests if the age is between 21 and 65 inclusive, and if not, asks the user for
another input. [3]

7 Edit your program so that it works for any number of employees. [2]

Save your program VARAGE2_<Class>_<Index>_<Name>.py


5

Task 3

A number is said to be an Armstrong number when the sum of its digits raised to the power of
the length of the number becomes equal to the number itself.

For example, 371 and 1634 are Armstrong numbers as follows:


33 + 73 + 13 = 371
14 + 64 + 34 + 44 = 1634

A computing student wrote the following program to display the list of Armstrong numbers from
a user-defined range of numbers. However, there are syntax and logical errors in the program.

result = []

print("***********The search for ARMSTRONG numbers!***********")


limit = int(input("Range is 1 to n inclusive. \nState your n: ")
print("Checking for ARMSTRONG numbers from 1 to {}".format(limit))

for number in range(1, limit+1)


power = len(number)
check = number
remainder = 0

while check != 0:
remainder = number%10
sum_digits += remainder*power
check = check%10

if sum_digits > number:


result.append(number)

print("The ARMSTRONG numbers are {}:".format(result))

##List of ARMSTRONG numbers


##1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407,
##1634, 8208, 9474, 54748, 92727, 93084, 548834, ...

Open the file TASK3.py


Save the file as ARM_<Class>_<Index>_<Name>.

8 Identify and correct the errors in the program so that it works correctly according to
the rules given. Save your program. [10]

4E Computing P2 2020 Prelim [Turn over


6

Task 4

You have been asked to write a program to simulate the Atbash Cipher.

The Atbash Cipher is a substitution cipher with a specific key where the letters of the alphabet
are reversed; i.e. all 'A's are replaced with 'Z's, all 'B's are replaced with 'Y's, and so on. It was
originally used for the Hebrew alphabet, but can be used for any alphabet.

The table below shows how the cipher works for the Latin alphabet.

The plaintext of “HELLO” will be encrypted as “SVOOL” based on the cipher.


The program should allow you:
• To enter a plaintext in uppercase or lowercase.
• To encrypt the plaintext.
• Not to encrypt non-letter characters.
• To display the encrypted message on the screen. Your output must look like this:
Please enter your plaintext: Hello World!
Encrypted message: SVOOL DLIOW!

9 Write your program and test that it works. [12]

Save your program as CIPHER1_<Class>_<Index>_<Name>.

10 When your program is working, use the following plaintexts as test data to show
your test results:

Test case Expected Output


Hello World! Encrypted message: SVOOL DLIOW!
JUNYUAN SEC Encrypted message: QFMBFZM HVX
ice-CREAM rules Encrypted message: RXV-XIVZN IFOVH

Take a screen shot of your results and save it as a bitmap


CIPHERRESULT_<Class>_<Index>_<Name>. [3]
7

11 Save your program as CIPHER2_<Class>_<Index>_<Name>.

Extend your program to also allow user to choose to do a double encryption. [5]

A double encryption will flip the original encrypted message and add ‘%’ after
every two characters. A sample output could look like this:
Enter 1 for Single-level encryption
or 2 for Double-level encryption: 2
Please enter your plaintext: hello world!
Encrypted message: !W%OI%LD% L%OO%VS%

Save your program.

End of Paper

4E Computing P2 2020 Prelim [Turn over


8

BLANK PAGE

You might also like