0% found this document useful (0 votes)
12 views6 pages

Jyss 2018 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)
12 views6 pages

Jyss 2018 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/ 6

JUNYUAN SECONDARY SCHOOL

PRELIM EXAMINATION 2018


SECONDARY FOUR EXPRESS

CANDIDATE NAME

CLASS INDEX NUMBER

COMPUTING 7155/02
Paper 2 (Practical) 26 July 2018 / Thursday
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

READ THESE INSTRUCTIONS FIRST


Answer ALL questions.

All tasks must be done in the exam venue. 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 6 printed pages and 2 pages of Quick Reference for Python.
[Turn over]
2

Task 1
Maynot Bank uses a spreadsheet for its customer loan records. You are required to finish
setting up the spreadsheet to record the monthly repayment data.

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

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

1 For the cell range C10:C19, use an appropriate function to extract the first letter
of the Customer Code to represent the Loan Type. [1]
2 Use an appropriate function to search for the Interest Rate per Year in the
Interest Rate Table given and use it to complete the Interest Rate column. [2]
3 Enter a formula to calculate the simple interest payable by the customers and
use it, together with the Loan Amount, to complete the Total Amount of
Repayment column. [3]
4 Enter a formula to calculate the monthly amount repayable per customer and
use it to complete the Monthly Repayment column. [2]
5 Use a conditional statement, to identify those customers who have undertaken
a loan repayment period of more than 3 years and whose application method
was online, and put YES in the Free $50 Cash-back column. Otherwise, put
NO in the Free $50 Cash-back column. [2]
Save and close your file.
3

Task 2
The following program accepts the weight in kilograms (kg) for 10 students and prints out
the largest weight and the average weight. The weights are in the range of 40 kg to 100 kg.

largest = 0
total = 0
student = 10

for i in range(student):
weight = float(input("Enter weight of student: "))
if weight > largest:
largest = weight
total = total + weight

average = round(total/student, 1)
print("Largest weight is ", largest, "kg")
print("Average weight is ", average, "kg")

Open the file TASK2.py

6 Edit the program, so that it:


(a) Accepts the weight for 40 students. [1]

(b) Prints out the smallest weight. [4]

(c) Tests if the weight input is between 40 and 100 (both inclusive), and if not,
inform the user that it is an invalid input and asks the user for input again [3]
as necessary.

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

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

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

4E Computing P2 2018 Prelim [Turn over


4

Task 3
The Singapore Flying Academy has a requirement that its student pilots must have a height
between 165 cm and 190 cm (both inclusive). The following program prompts the user to
enter the height of the applicant. The program will calculate and display the number of
applicants that are accepted and the number of applicants that are rejected. The program
uses the following rules:
• The height is entered as an integer value.
• The program will terminate when a height of 0 or no data is entered.

There are several syntax and logical errors in the program.

height=0
accepted=0
rejected=100
input_str=input("Enter height in cm: )

while input_str != "" or height != "0":


height=int(input_str)
if height > 165 and height < 190:
accepted = accepted + 1
else:
rejected = rejected - 1

input_string=input("Enter height in m: ")

print("Total accepted = ",height)


print("Total rejected = ",rejected)

Open the file TASK3.py


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

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

Save your program.


5

Task 4
You have been asked to write a program for a department store to calculate the average
number of t-shirts sold per week by a particular brand. The t-shirts come in 5 sizes, XS, S,
M, L and XL. The store only keeps 20 pieces of each size in stock for each day.

The program should allow you to:


• Enter data in the format a, b, c, d, e where a, b, c, d, e are the sizes, XS, S, M, L, XL
respectively that are sold at a store for a day. An example is 10, 20, 9, 10, 0.
• Only allow data entry of 0 to 20 for each size sold each day, otherwise exit the program
• Calculate the total number of t-shirts sold each day
• Repeat this for a total of seven days
• Find the average number of shirts sold per day rounded to the nearest whole number
• Calculate the total number of shirts sold for the week.
• Display this on the screen. Your output must look like this:

Day 1 Total shirts: 49


Day 2 Total shirts: 47
Day 3 Total shirts: 26
Day 4 Total shirts: 60
Day 5 Total shirts: 25
Day 6 Total shirts: 63
Day 7 Total shirts: 29
Average number of shirts sold per day: 43
Total number of shirts sold for the week: 299

9 Write your program and test that it works.


Save your program as TSHIRT1 _<Class>_<Index>_<Name>. [10]
10 When your program is working, use the following test data to show your test
results:
10, 20, 9, 10, 0
2, 13, 4, 19, 9
0, 10, 2, 3, 11
15, 20, 0, 6, 19
0, 10, 0, 15, 0
13, 12, 11, 17, 10
3, 7, 6, 4, 9

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


TSHIRTRESULTS_<Class>_<Index>_<Name>. [5]

4E Computing P2 2018 Prelim [Turn over


6

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

Extend your program to identify the sales of the t-shirts by their sizes. Print out
the size of the t-shirt and the total number of that size sold in the week. Your
output should look like this:

Size XS Total shirts: 43


Size S Total shirts: 92
Size M Total shirts: 32
Size L Total shirts: 74
Size XL Total shirts: 58
[3]

Save your program.

12 Save your program as TSHIRT3_<Class>_<Index>_<Name>


The owner of the t-shirt brand decided to expand his t-shirt size range by
changing the sizes to numeric values. E.g. 1, 2, 3, 4, 5, 6.

Extend your program to work for any numeric range of t-shirt sizes by asking the
user to input the minimum and maximum sizes. [2]

Save your program.

End of Paper

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy