0% found this document useful (0 votes)
42 views7 pages

SPS 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)
42 views7 pages

SPS 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/ 7

ST.

PATRICK'S SCHOOL
PRELIMINARY EXAMINATIONS 2020
SECONDARY 4 EXPRESS
NAME

CLASS INDEX
NUMBER

COMPUTING 7155/02
Paper 2 (Lab-based) 24 August 2020
2 h 30 min
Additional Materials: Electronic version of THEMEPARK.xlsx data file
Electronic version of GARGLE.py file
Electronic version of INTEGERS.py file
Quick Reference Glossary

READ THESE INSTRUCTIONS FIRST


Write your name, class, index number in the spaces at the top of this page.
Write in dark blue or black pen.

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


Parent’s Signature : ____________________________
Date: ____________________________ Marks
/50

Remarks (if any) : Total

This document consists of 7 printed pages including this page and ANNEX A.
2

[Turn over
3

[Turn over
4

Task 1
A holiday theme park, Theme Park Pte Ltd uses a spreadsheet software to calculate their ticket
sales. You are required to finish setting up the spreadsheet to calculate the revenue gained for
each transaction number.

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

Save the file as MYTHEMEPARK_<Class>_<Class_Index_Number>_<Your_Name>

1 The fifth character of each Transaction Number is the Code of the Package Name. In cells [2]
C7 to C16 enter a formula that uses an appropriate function to search for the Package Name
in the Package table. Use it to display the Package Name.

2 In cells E7 to E16 enter a formula that uses an appropriate function to search for the Price in [2]
the Package table. Use it to calculate the Full Cost in currency format.

3 In cells G7 to G16 enter a formula that uses an appropriate function to search for the [2]
Discount in the Discount table. Use it to calculate the Discount given in currency format.

4 In cells H7 to H16 enter a conditional statement to calculate the Revenue. If the Transaction [2]
Type is CORPORATE, apply an additional 2% of the Revenue.

5 In cells F36 to H36 enter a conditional statement to calculate the number of each Transaction [2]
Type.

[Turn over
5

Task 2
The following program creates a Gargle Suite account for a user. It creates the username by
taking the first letter of the user’s name and combining it with the user’s ID. It will also allow the
user to enter a password.

name = input("Please enter your full name: ")


id = input("Please enter your ID: ")
username = name[0] + id
print("Your username is " + username)
password = input("Please enter a password: ")

Open the file GARGLE.py.

Save the file as MYGARGLE_<Class>_<Class_Index_Number>_<Your_Name>.py

6 Edit the program so that the username is created using the first 5 characters of the user’s [3]
name and combining with the last 5 characters of the user’s ID. The program should also
ignore any spaces in the user’s name when creating the username.

7 The program needs to validate both the password and whether the user has correctly re-
entered their password.

(a) Edit the program to:

• test whether the user has entered a password of eight characters or more and
that it consists of at least 1 capital letter, 1 small letter and 1 numeral.
• output a suitable error message that asks the user to enter a password again if
the password does not meet the above criteria, and repeat this until the user
[3]
enters a valid password.

(b) Edit the program to:

• ask the user to re-enter their password (i.e. second entry of password)
• output a suitable error message that asks the user to enter a new password if the
second entry of the password does not match the first entry, and repeat this until
the user enters a valid password and the second entry matches the first entry of
the password.
• output the user’s username and email address in this format:
Your account has been set up successfully.
Your username is ElgooG2020
Your email address is [email protected] [4]

Save your program.

[Turn over
6

Task 3
The following program asks user to input a series of integers and checks whether the integer
is a positive, negative or zero. The program also outputs the list of integers in ascending
order. The program quits when the user enters "q".

There are several syntax and logic errors in the program.

data
negatives = []
positives = []
zeroes = []
num_zeroes = 0

num = int(input("Enter an integer (q to quit): "))


while num != q:
num = num
data.extend(num)
if num < 0:
negatives.append(num)
elif num > 0:
positives.append(num)
else
zeroes.append(num)
num = input("Enter an integer (q to quit): ")

data = sort()
print("\nThe integers, sorted in ascending order, are: {}\n".format(data))

print("\nThe negative values are: ")


for num in negatives:
print(num)

print("\nThe positive values are: ")


for num in positives:
print(num)

num_zeroes = count(zeroes)
print("\nThere are {} zeroes.", num_zeroes)

Open the file INTEGERS.py.

Save the file as MYINTEGERS_<Class>_<Class_Index_Number>_<Your_Name>.py

8 Identify and correct the errors in the program so that it works according to the requirements [10]
given.

Save your program.

[Turn over
7

Task 4
You have been asked to create an unscrambling word game program. This program
simulates a two-player game. Player 1 enters a word. The program then scrambles it for
Player 2 to figure out Player 1’s word.

The program should:

• allow Player 1 to input a word of length between 3 and 45, for Player 2 to unscramble.
Instruct Player 1 to only enter lowercase letters from the English alphabet. There must
be a validation present to check that the word entered is within the above characters
limit and that it is made up of only lowercase letters from the English alphabet.
• allow Player 2 to have three attempts to correctly unscramble the word input by Player
1. You do not need to validate the input for Player 2.
• output an appropriate message when Player 2 manages to unscramble correctly and
inputs the same word entered by Player 1. The game ends when Player 2
unscrambles correctly.
• output an appropriate message when Player 2 does not input the same word entered
by Player 1.
• output an appropriate message when Player 2 has 3 incorrect attempts. The game
must also end here.

9 Write your program and test that it works.


Save your program as MYWORD1_<Class>_<Class_Index_Number>_<Your_Name>.py [10]

10 When your program is complete, test it for the following:

• Test 1: Player 1 inputs the word “ISOSCELES”


• Test 2: Player 1 inputs the word “an”
• Test 3: Player 1 inputs the word “triangle” and player 2 enters “traingle” and “triangle”.
• Test 4: Player 1 inputs the word “hen” and player 2 enters “neh”, “enh”, “nhe”.
Take a screenshot of:

• Test 1, 2, 3 and 4. Save this single screenshot as:


TEST1234_<Class>_<Class_Index_Number>_<Your_Name>
Save your file in either .png or .jpg format. [4]

11 Save your program as MYWORD2_<Class>_<Class_Index_Number>_<Your_Name>.py

Extend your program to keep track of the number of attempts left for Player 2. Outputs a
suitable message on the number of attempts left before asking Player 2 to enter his word.

Save your program. [2]

12 Save your program as MYWORD3_<Class>_<Class_Index_Number>_<Your_Name>.py

Extend your program to allow Player 2 to choose an easy, medium or hard game. An easy
game allows five attempts, a medium game allows three attempts and a hard game allows
two attempts.

Save your program. [4]

End of Paper

You might also like