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

Pathlight 2020 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)
14 views

Pathlight 2020 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/ 10

PATHLIGHT SCHOOL

PRELIMINARY EXAMINATION
SECONDARY 4 EXPRESS
CANDIDATE
NAME

CENTRE
NUMBER S INDEX
NUMBER

COMPUTING 7155/02
Paper 2 Practical (Lab-based) August 2020

2 hours 30 minutes
Additional Materials: Electronic version of FEELOAN.xlsx data file
Electronic version of TEMP_CHECK.py file
Electronic version of INTEGER.py file
Insert Quick Reference Glossary
READ THESE INSTRUCTIONS FIRST

Write your Centre number, Index number and name in the spaces at the top of this page.

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 marks for this paper is 50.

This document consists of 8 printed pages, 2 blank pages and 1 insert.


[Turn over
2

Task 1
BCOC bank provides school fee loan (based on a yearly compounded interest scheme) to new
tertiary students. The bank manager wants to use spreadsheet software to record the details of
the transactions in the first quarter of 2020.
You are required to finish setting up the spreadsheet to record the interest each student needs to
pay back. Do note that the repayment of the loan is only done at the end of the loan period (i.e.
only lump sum payment accepted)

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

Save the file as MYFEELOAN_<your name>_<centre number>_<index number>.xlsx


1 In cell C20 enter a formula to calculate the total loan amount of all transactions. [1]

2 The fourth to fifth characters of the Transaction ID indicates the age of the student.
For example, Transaction ID STL23ER indicates that student’s age is 23 years old.
In cells B4 to B18 enter a formula to calculate the age of the student and use it to complete
the Age column.
[1]

3 In cell C21 enter a formula to count the number of transactions made. [1]
3

4 In cell C22 enter a formula to calculate the range of the number of years loaned. [1]

5 In cells E4 to E18 enter a formula that uses an appropriate function to search for the
Interest Rate per Annum in the Rates table and use it to complete the Interest Rate
column. [1]

6 Format all cells in the Interest Rate column to automatically show a red text for values of
more than 1.5%. [1]

7 Enter a formula to calculate the total interest payable by students at the end of the loan
period and use it to complete the Total Interest Payable column.
(Hint: Total interest payable = Total Lump Sum Payment of the Loan – Principal Amount of
the Loan) [2]

8 In cells G4 to G18 enter conditional statement(s), to identify students who have loaned at
least $50,000 or have a loan period of more than 5 years and put ENTITLED in the Free
Laptop column. Otherwise put NO in the Free Laptop column. [2]
Save and close your file.

Task 2 begins on the next page.

[Turn over
4

Task 2

The following program checks whether the student is able to attend school. It requires the
input of body temperature for 25 students, an input of any cough or flu symptoms for each
student and prints out if he/she is fit to attend school.

student_no = 25
for i in range(student_no):
temperature = float(input("Enter temperature in degree C: "))
symptom = input("Do you have any flu/cough symptoms? (Y/N): ")
if temperature >= 38:
print("You are having fever. Stay home & consult a doctor ")
if symptom == 'Y':
print("You are having flu/cough symptoms. Stay home &
consult a doctor")

Open the file TEMP_CHECK.py

Save the file as TEMP_CHECK_<your name>_<centre number>_<index number>.py

8 Edit the program so that it:

(a) Accepts temperature and flu/cough symptoms input for only 10 students. [1]

(b) Prints out the following data


• number of students whose temperature (in degree C) is 38 and above
• number of students who has flu or cough symptoms. [4]

(c) Tests if the temperature is between 34 to 42 (inclusive), and if not, asks the user for
temperature input again as necessary. [3]

Save your program.

9 Save your program as TEMPMULTIPLE_<your name>_<centre number>_<index


number>.py

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

Save your program.


5

Task 3

The following program below reads positive integer(s) entered by a user. It stops when “end” is
entered.
If the user enters anything else, the program will print an error message and ask the user to enter
the input again. Before the program exits, it will print the following:

• number of valid values given


• sum of all valid values
• average of all valid values
• number of even valid numbers

There are several syntax and logic errors in the program.

total = 1
even = 0
count = 0
while True
x = input"Enter a positive integer. Type 'end' to finish."
if x = "end":
break
elif x.isdigit():
print ("Invalid input. Try again.")
else:
x = integer(x)
if x // 2 == 0:
even += 1
total -= x
count += 1
average = round(total/count, 1)
if count == 0:
x = 0
average = "NA"
total = "NA"

print("\nYou have entered {} number(s)".format(count))


print("\nThe sum of all number(s) entered is {}".format(total))
print("\nThe average of the number(s) entered is
{}".format(average)
print("\nNumber of odd number(s) entered is {}".format(even))

Open the file INTEGER.py

Save the file as MYINTEGER_<your name>_<centre number>_<index number>.py


6

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

Task 4 begins on the next page.

[Turn over
7

Task 4

Hangman is a popular word guessing game for 2 players.

Below is a description of the game features:

• Player A thinks of a word but will not reveal to Player B who is guessing
• Instead, Player A will reveal the number of characters (asterisks) that corresponds
to the word he/she has in mind.
• Player B then guesses an alphabetical letter.
• If the guess is correct, the letter(s) will reveal themselves.
• If the guess is incorrect, Player B will have used up 1 try
• If all letters are not revealed by the end of 6 tries, Player B will lose and program will
end with an output of a specific message.
• If all letters are revealed before then, Player B will have won the game and program
will end with an output of a specific message.

Below are 2 samples of how the game can be played using the game program.

Do note that the word given for the game program by Player A is ‘mammals’.

Sample 1

Make a guess of an alphabetical letter: t


No letters available! Tries left: 5
*******
Make a guess of an alphabetical letter: q
No letters available! Tries left: 4
*******
Make a guess of an alphabetical letter: f
No letters available! Tries left: 3
*******
Make a guess of an alphabetical letter: m
Nice! Tries left: 3
m*mm***
Make a guess of an alphabetical letter: o
No letters available! Tries left: 2
m*mm***
Make a guess of an alphabetical letter: l
Nice! Tries left: 2
m*mm*l*
Make a guess of an alphabetical letter: z
No letters available! Tries left: 1
m*mm*l*
Make a guess of an alphabetical letter: y
No letters available! Tries left: 0
m*mm*l*
Sorry, you have failed to guess the word. Game Over.
8

Sample 2

Make a guess of an alphabetical letter: m


Nice! Tries left: 6
m*mm***
Make a guess of an alphabetical letter: a
Nice! Tries left: 6
mamma**
Make a guess of an alphabetical letter: l
Nice! Tries left: 6
mammal*
Make a guess of an alphabetical letter: o
No letters available! Tries left: 5
mammal*
Make a guess of an alphabetical letter: s
Nice! Tries left: 5
mammals
Congrats! You have guessed the word.

11 You have been asked to create the game program.

Your program should work accordingly to the 2 above mentioned samples. [13]

(Hint: It would be helpful to start your program containing at least 2 variables of suitable data
types)

Save your program as HANGMAN_<your name>_<centre number>_<index number>.py

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

• Test 1 – Player B inputs accordingly to the inputs given in Sample 1


• Test 2 – Player B inputs accordingly to the inputs given in Sample 2

Take a screenshot of Test 1. Save this screenshot as:

TEST1_<your name>_<centre number>_<index number>

Take a screenshot of Test 2. Save this screenshot as:

TEST2_<your name>_<centre number>_<index number>

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

A programmer has decided to modify the game program such that it works for any word Player A
enters.

13 Save your program as RANDOMHANGMAN_<your name>_<centre number>_<index


number>.py

Extend your program so that it works for any word Player A enters. [4]

Save your program.


9

BLANK PAGE
10

BLANK PAGE

You might also like