Jyss 2018 P2
Jyss 2018 P2
CANDIDATE NAME
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
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.
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.
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.
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")
(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.
7 Edit your program so that it works for any number of students. [2]
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.
height=0
accepted=0
rejected=100
input_str=input("Enter height in cm: )
8 Identify and correct the errors in the program so that it works correctly according
to the rules above. [10]
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.
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:
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]
End of Paper