TSS 2019 P2 Solution
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Sec 4 Computing Prelim 2019 P2 Ans Scheme 1 E3=TODAY() [1m] 2 E12=ROUND(B13/(B12^2),1) OR ROUND(B13/(B12*B12),1) OR ROUND(B13/POWER(B12,2),1) -1m if not shown in 1dp or brackets missing [2m] 3 E13=VLOOKUP(E12,D25:E27,2,TRUE) [1m] 4 E15=IF(AND(B14<120,B15<80),E31,IF(AND(B14>140,B15>90),E33,E32) -1m if not referenced using cell address [2m] 5 E20=SUM(B20, B21) OR SUM(B20:B21) [1m] 6 E21= ROUND(B21/E20,2) OR B21/E20 with formatting to zero decimal place -1m if not shown in percentage/whole numbers -1m if not referenced using cell address [2m] 7 [1m]
8b 8a number = int(input("Enter a positive integer: ")) while int(number)<=0: number=int(input("Re-enter a positive integer: ")) count=0 print("Factors of this integer are: ") for factor in range(2, number): if number % factor == 0: count+=1 print(factor) print("There are a total of {} factors.".format(count)) [1m] [1m] [1m] [1m] 9b 9a number = int(input("Enter a positive integer: ")) print("Factors of this integer are: ") for factor in range(2, int(number**0.5)+1): if number % factor == 0: print(factor,"x",number//factor) 9a: 1m – find corresponding factor using floor division 1m – proper output, line by line 1m – output both 9b: 1m – identify repeated factors or use sqrt, 1m – remove repeated, 1m – exclude 1 and itself [3m] [3m]
10 print(" ~~Drinks Menu~~ ") drinks=["Hot Coffee", "Hot Tea", "Canned Drink", "Bottled Drink"] prices=[4,3,2.5,3.5] for option in range(len(drinks)): print(str(option+1)+"- "+drinks[option]+"\t$"+str(prices[option])) choice=int(input("\nEnter your choice: ")) owe=prices[choice-1] print("\n"+drinks[choice-1]+" costs $"+str(owe)+".") paid=0 valid=["0.1","0.2","0.5","1","2","5","10"] while paid<owe: cash=input("Please insert cash(\"x\" to cancel): ") if cash in valid: paid+=float(cash) elif cash=="x": print("Your order is cancelled.") owe=0 else: print("Invalid currency!") print("\nBalance payment is $"+str(owe-paid)+".") if paid>owe: print("\n$"+str(paid-owe)+" has been returned to you.") if cash!="x": print("Your "+drinks[choice-1]+" has been served. Enjoy!") [1m] [1m] [1m] [1m] [1m] [1m] [1m] [1m] [1m] [1m] A B C D D E F G I H J D
11 Ask user for an input date (e.g. DD/MM/YYYY) and store it appropriately. Validation if input has D, M and Y being digits and length is 10. Use while-loop to ask user to re-enter input if valid Separate DD, MM and YYYY using indexing or slicing and store in appropriate variables Use mod (%) in conditions to determine leap year Use if-else logically to determine leap year Use list to store data on how many days in a month, and 1 ≤ month ≤ 30 Use if-else logically to determine if day correspon
Content continues in the PDF.
Related notes
- Computing o level notes Notes/Practices · 2023
- BVSS Prelim P1 MSExam Papers · 2024
- BVSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices

