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

ACSBR 2020 Computing P2 Solution

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)
22 views7 pages

ACSBR 2020 Computing P2 Solution

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

SECONDARY FOUR EXPRESS

COMPUTING
PRELIMINARY EXAMINATION

Solution Paper 2

Task 1
ORDERS_sample - Formula view

Question Answer Marks


One mark for correct working HLOOKUP with FALSE lookup (top [2]
formula), One mark for the rest
1
=HLOOKUP(B3,B$26:F$27,2,FALSE)

Question Answer Marks


2 One mark for correct conditional statement. One mark for multiplying [2]
with Basic Price.

=IF(C3="Luxury",0.2,IF(C3="Deluxe",0.1,IF(C3="Classic",0)))*D3

Question Answer Marks


3 One mark for summing up Basic Price and Package Price. [1]

=D3+E3

4 One mark for multiplying Loan% to get the Loan amount [1]

=F3*G3

Question Answer Marks

Secondary 4 Express 1 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020
5 One mark for correct working VLOOKUP with TRUE lookup (top [2]
formula. One mark for the rest

=VLOOKUP(I3,A$33:C$36,3,TRUE)

Question Answer Marks


6 One mark for working top formula. (Accept negative answers) [1]

=-PMT(J3/12,I3*12,H3,0)

Question Answer Marks


7 One mark for working top formula. [1]

=COUNTIF($B3:$B22,B26)

Secondary 4 Express 2 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020
Task 2

MYBMI
students = 15
upp_bound = 25
low_bound = 18.5
underwt, overwt = 0, 0

for count in range(students):


weight = float(input('Enter weight of student in kg '))
height = float(input('Enter height of student in cm '))
bmi = weight/height**2 * 10000
if bmi > upp_bound:
print('Student is overweight')
overwt += 1
elif bmi < low_bound:
print('Student is underweight')
underwt += 1
else:
print('Student\'s weight is normal')

print("Number of overweight students ", overwt)


print("Number of underweight students ", underwt)

MYBMI2
students = int(input("Enter number of students "))
upp_bound = 25
low_bound = 18.5
underwt, overwt = 0, 0

for count in range(students):


weight = float(input('Enter weight of student in kg '))
while weight < 30 or weight > 150:
print('Invalid weight')
weight = float(input('Enter weight of student in kg '))
height = float(input('Enter height of student in cm '))
while height < 80 or height > 200:
print('Invalid height')
height = float(input('Enter height of student in cm '))
bmi = weight/height**2 * 10000
if bmi > upp_bound:
print('Student is overweight')
overwt += 1
elif bmi < low_bound:
print('Student is underweight')
underwt += 1
else:
print('Student\'s weight is normal')

print("Number of overweight students ", overwt)


print("Number of underweight students ", underwt)

Secondary 4 Express 3 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020
Task 3

MYMARKS
nlist = ["Alden", "Belle", "Charles", "Dolly", "Elle", "Falken", "Grace",
"Hacken"]
mlist = [56, 64, 23, 78, 53, 46, 98, 33]

to_find = input("Which name would you like to search for? ")

items = len(nlist)
num = 0
name_found = False
while name_found == False:
while num < items:
if nlist[num] == to_find:
print("{} score {} for the test".format(nlist[num], mlist[num]))
name_found = True
num = items
elif num == items - 1:
print("{} is not in the list".format(to_find))
name_found = True
num = items
else:
num += 1

Question Answer Marks


10 One mark for correct list syntax
mlist = [56, 64, 23, 78, 53, 46, 98, 33] [1]
One mark for getting correct number of items
items = len(nlist) [1]
One mark for correct while condition
while name_found == False: [1]
One mark for correct while condition
while num < items: [1]
One mark for correct syntax and one mark for : [1]
if nlist[num] == to_find: [1]
One mark for correct index
print("{} score {} for the test".format(nlist[num], [1]
mlist[num]))
One mark for correct logic
num = items [1]
One mark for correct logic
name_found = True [1]
One mark for incrementing
num += 1 [1]

Secondary 4 Express 4 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020
Task 4

TPSTAFF
no_staff = 5

staff_list = []
time_in = []
time_out = []
work_time = []
wage = []

for i in range(no_staff):
staff = input("Enter name of staff: ")
staff_list += [staff]
tin = input("Time-in HH:MM for {}: ".format(staff))
while not (tin[:2].isdigit() and tin[2] == ":" and tin[-
2:].isdigit()\
and len(tin) == 5 and 0 <= int(tin[:2]) <= 23 and 0 <=
int(tin[-2:]) <= 59):
tin = input("Invalid! Time-in HH:MM for {}:
".format(staff))
time_in += [tin]

tout = input("Time-out HH:MM for {}: ".format(staff))


while not (tout[:2].isdigit() and tout[2] == ":" and tout[-
2:].isdigit()\
and 0 <= int(tout[:2]) <= 23 and 0 <= int(tout[-2:])
<= 59 and len(tout) == 5\
and (int(tout[:2])> int(tin[:2]) or int(tout[:2])
== int(tin[:2]) and \
int(tout[-2:]) >= int(tin[-2:]))):
tout = input("Invalid! Time-out HH:MM for {}:
".format(staff))
time_out += [tout]
work = (int(tout[:2])- int(tin[:2]))*60 + int(tout[-2:]) -
int(tin[-2:])
work_time += [work]

print()
for i in range(no_staff):
print("{} worked for {} minutes".format(staff_list[i],
work_time[i]))

print()
print("Average number of minutes worked:
{}".format(round(sum(work_time)/len(work_time),1)))

Secondary 4 Express 5 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020
RESULT screenshot
Enter name of staff: Andy
Time-in HH:MM for Andy: 08:05
Time-out HH:MM for Andy: 13:55
Enter name of staff: Ben
Time-in HH:MM for Ben: 07:03
Time-out HH:MM for Ben: 07:00
Invalid! Time-out HH:MM for Ben: eight o'clock
Invalid! Time-out HH:MM for Ben: 08:00
Enter name of staff: Charles
Time-in HH:MM for Charles: 10:03
Time-out HH:MM for Charles: 13:115
Invalid! Time-out HH:MM for Charles: 13:11
Enter name of staff: Dominic
Time-in HH:MM for Dominic: 09-04
Invalid! Time-in HH:MM for Dominic: 09:04
Time-out HH:MM for Dominic: 15:35
Enter name of staff: Ethan
Time-in HH:MM for Ethan: 08:42
Time-out HH:MM for Ethan: 16:55

Andy worked for 350 minutes


Ben worked for 57 minutes
Charles worked for 188 minutes
Dominic worked for 391 minutes
Ethan worked for 493 minutes

Average number of minutes worked: 295.8

TPSTAFF2 (appended to TPSTAFF)


print()
for i in range(no_staff):
if work_time [i] <= 240:
wage = work_time[i]//15*3
else:
wage = (work_time[i]-240)//15*4 + 240//15*3
print("{} will be paid ${}".format(staff_list[i], wage))

TPSTAFF3
staff_list = []
time_in = []
time_out = []
work_time = []
wage = []
staff = input("Enter name of staff: ")

while staff != '':


staff_list += [staff]
tin = input("Time-in HH:MM for {}: ".format(staff))

Secondary 4 Express 6 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020
while not (tin[:2].isdigit() and tin[2] == ":" and tin[-
2:].isdigit()\
and len(tin) == 5 and 0 <= int(tin[:2]) <= 23 and 0 <=
int(tin[-2:]) <= 59):
tin = input("Invalid! Time-in HH:MM for {}:
".format(staff))
time_in += [tin]

tout = input("Time-out HH:MM for {}: ".format(staff))


while not (tout[:2].isdigit() and tout[2] == ":" and tout[-
2:].isdigit()\
and 0 <= int(tout[:2]) <= 23 and 0 <= int(tout[-2:]) <=
59 and len(tout) == 5\
and (int(tout[:2])> int(tin[:2]) or int(tout[:2])
== int(tin[:2]) and \
int(tout[-2:]) >= int(tin[-2:]))):
tout = input("Invalid! Time-out HH:MM for {}:
".format(staff))
time_out += [tout]
work = (int(tout[:2])- int(tin[:2]))*60 + int(tout[-2:]) -
int(tin[-2:])
work_time += [work]
staff = input("Enter name of staff: ")

print()
for i in range(len(staff_list)):
print("{} worked for {} minutes".format(staff_list[i],
work_time[i]))

print()
print("Average number of minutes worked:
{}".format(round(sum(work_time)/len(work_time),1)))

print()
for i in range(len(staff_list)):
if work_time [i] <= 240:
wage = work_time[i]//15*3
else:
wage = (work_time[i]-240)//15*4 + 240//15*3
print("{} will be paid ${}".format(staff_list[i], wage))

End of Answer Key

Secondary 4 Express 7 Computing 7155/02


Anglo-Chinese School (Barker Road) Preliminary 2020

You might also like