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

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

SPS 2019 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 2019
SECONDARY 4 EXPRESS
NAME

CLASS INDEX
NUMBER

COMPUTING 7155/02
Paper 2 Practical (Lab-based) 2 September 2019
2 h 30 min
Additional Materials: Electronic version of RESORT.xlsx data file
Electronic version of DISARIUM.py file
Electronic version of RATING.py file
Insert Quick Reference Glossary (ANNEX A)

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 resort, Red Resort uses spreadsheet software to calculate the cost of a holiday for
each customer. The resort has five types of rooms and offers 20% discount for members. You
are required to finish setting up the spreadsheet to calculate the cost for each customer.

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

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

1 In cell C20 enter a formula to count the number of customers. [1]

2 In cell C21 enter a formula to count the number of Members. [1]

3 Use an appropriate function to search for the Cost per Night in the Room Type table, and [2]
use it to complete the Cost column. The cost must take into consideration the Number of
Nights each customer is staying.

4 Use a conditional statement to identify whether a customer will receive the Discount. Only [2]
members will receive a 20% discount and the corresponding cells must display this discount.

5 Use a conditional statement to calculate the total cost of each customer’s stay at the resort in [2]
the Total Cost column. The Total Cost must take into account any discount given to the
customer.

6 In cell H20 enter a formula to calculate the average revenue for the month. If the average [2]
revenue exceeds $400, use conditional formatting to fill cell H20 with green colour.

[Turn over
5

Task 2
At a particular company, employees are rated at the end of each year. The rating scale begins
at 0.0, with higher values indicating better performance and resulting in larger raises. The value
awarded to an employee is either 0.0, 0.5, or 0.6. Values between 0.0 and 0.5, and between 0.5
and 0.6 are never used. The meaning associated with each rating is shown in the following
table. The amount of an employee’s raise is $2600.00 multiplied by their rating.

Rating Meaning
0.0 Unacceptable performance
0.5 Acceptable performance
0.6 Satisfactory performance

The program below displays whether an employee’s performance rating and his raise based on
the rating entered by the user.

RAISE_FACTOR = 2600.00
D = 0.0
C = 0.5
B = 0.6

rating = float(input("Enter the rating: "))

if rating == D:
performance = "Unacceptable"
elif rating == C:
performance = "Acceptable"
elif rating == B:
performance = "Satisfactory"
else:
performance = ""

if performance == "":
print("Invalid rating.")
else:
print("Based on that rating, the performance is %s." % performance)
print("The employee’s raise is $%.2f." % (rating*RAISE_FACTOR))

Open the file RATING.py.

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

7 Edit the program so that:

(a) If the rating is A, the performance is “Meritorious”, where rating A means 0.7 or more. [2]

(b) It prompts the user to enter the name of the employee and displays this name before it [2]
outputs the performance category and raise.

(c) When an invalid rating is entered, the program displays an error message and prompts the [3]
user to re-enter using the correct rating.
Save your program.

8 Save the file as VARPERFORMANCE_<Class>_<Class_Index_Number>_<Your_Name>.py [3]


Edit your program so that it works for any number of employees, as determined by the user.

[Turn over
6

Task 3
A number is said to be the Disarium number when the sum of its digits raised to the power of
their respective positions becomes equal to the number itself.

For example, 175 is a Disarium number as follows:

11+ 72 + 53 = 1+ 49 + 125 = 175

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

result = []

limit = int(input("Range of numbers to be tested is 1 to n inclusive. State


your n: ")
print("The program is now checking for disarium numbers from 1 to
{}...".format(limit))

for number in range(1, limit+1)

remaining = 0
sum_digits = 0
number_str = number
counter = len(number_str)
test_number = number

while number > 0:


remaining = test_number%10
sum_digits += (remaining*counter)
test_number = test_number/10
counter -= 1

if sum_digits == number:
result = result.append(number)

print("The disarium numbers between 1 to {} are {}: ".format(limit,


result))

Open the file DISARIUM.py.

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

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

Save your program.

[Turn over
7

Task 4
You have been asked to create a program to determine the type of integer triangle from a
given set of dimensions. Your program should:

• Accept 3 integer lengths (in cm) of the desired triangle as input in the format a, b, c.
• Validate that there are exactly 3 positive integers in the input, and asks the user to re-
enter the input where necessary.
• Determine the type of triangle based on the input.

Type of Triangle Condition Output

Invalid The longest side of the The dimensions provided cannot


triangle is greater than the form a triangle.
sum of its two shorter sides
Equilateral All 3 sides are identical in You have entered an equilateral
length triangle.

Isosceles Only 2 of the 3 sides are You have entered an isosceles


identical in length triangle.

Scalene All sides are different in You have entered a scalene


length triangle.

10 Write your program and test that it works.


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

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

Side Input Expected Output


Test 1 2, 4, 10 The dimensions provided cannot form a triangle.
Test 2 6, 6, 6 You have entered an equilateral triangle.
Test 3 10, 6, 6 You have entered an isosceles triangle.
Test 4 3, 4, 5 You have entered a scalene triangle.

Take a screenshot of each of the above four tests and save as


TEST_<Test_Number>_<Class>_<Class_Index_Number>_<Your_Name> in either .png or
.jpg format. [5]

12 It is known from the converse of Pythagoras’ theorem that a triangle is right-angled if the sum
of the squares of its two shorter sides adds up to the square of its longest side.

It follows that a triangle is obtuse if the sum of the squares of its two shorter sides is smaller
than the square of its longest side.

Modify the program such that in addition to the aforementioned categories, it should also state
in its output if the triangle happens to be right-angled or obtuse.

Save your program as [5]


MYTRIANGLES2_<Class>_<Class_Index_Number>_<Your_Name>.py

End of Paper

You might also like