SST 2018 Prelim P2 Solution
SST 2018 Prelim P2 Solution
Task 1
2 1
3(a) 1
=IF(ROW(B10)-9>$B$4, "", ROW(B10)-9)
(Or equivalent)
3(b) 1
=IF(B10="","",CEILING(B10/12,1) )
=IF(B11="","",CEILING(B11/12,1))
…
=IF(B489="","",CEILING(B489/12,1))
(Or equivalent)
3(c) 1
=IF(B10="","",ABS(PMT(C10/12,$B$4,$B$2)))
(Or equivalent)
3(d) 1
=IF(B10="", "", ABS(IPMT(C10/12, B10, $B$4, $B$2)))
(Or equivalent)
3(e) 2
In cell G10: =IF(B10="", "", E10-F10)
In cell H10: =IF(B10="", "", D10-G10)
(Or equivalent)
1
3(f) copying formulae A10:H10 to rows 11 to 489. 1
4 1
Task 2
while True:
try:
income = int(input("({})Annual income in $: ".format(employee+1)))
if income < 0 or income > 120000:
raise Exception
except:
print("Please enter a value from 0 to 120000!")
else:
break
OR
5(c) 2
2
highestTax = 0
5(d) 1
if tax > highestTax:
highestTax = tax
n = employee + 1
5(e) 2
count = 0
…
if income <= 20000:
tax = 0
count += 1
…
print("Percentage who do not need to pay tax:
{}%.".format(round(count/size*100,1)))
3
Task 3
while True:
x = input('Enter a positive integer. Type "done" to finish.')
if x == "done":
break
elif not x.isdigit():
if count == 0:
M = m = x
else:
M = max(M, x)
m = min(m, x)
s += x
count += 1
if count==0:
average = s = M = m = "NA"
average = round(s/count, 1)
print("\nYou have entered {} number(s).".format(count))
4
Task 4
Question Answer Marks
8 while True: 12
i = input('Enter a string of digits or space:')
if any([not x in '0123456789 ' for x in i]):
print('Input error! Try again!')
else:
break
for x in '0123456789':
print('Frequency of {}: {}'.format(x, F[int(x)]))
5
Question Answer Marks
9 3
Enter : 3647 94859 8482 3209 832 45346
10 5
while True:
i = input('Enter a string of digits or space:')
if any([not x in '0123456789 ' for x in i]):
print('Input error! Try again!')
else:
break
for x in '0123456789':
print('Frequency of {}: {}'.format(x, F[int(x)]))