XMSS 2018 P2 Solution
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
1 4E Prelim Computing 2018 P2 Task 1 1 =C4*12 . . . =C15*12 [3] 2 =VLOOKUP(E4,$B$20:$E$24, IF(C4=1, 2, IF(C4=3, 3, 4)), FALSE) . . . =VLOOKUP(E15,$B$20:$E$24, IF(C15=1, 2, IF(C15=3, 3, 4)), FALSE) [4] 3 =FV(F4,D4,0,B4) . . . =FV(F15,D15,0,B15) [3] Total [10] Task 2 4a num_of_words = 5 [1] 4b print("Total number of characters =", len(result)) [1] 4c word_list = [] for count in range(num_of_words): word = input("Enter a word: ") word_list.append(word) result += word if count < num_of_words-1: result += " " print("Word List:") for w in word_list: print(w) [5] 4d while len(word)<1 or len(word)>15: word = input("Please enter correct length of word (1 to 15 char): ") [3]
2 Total [10] Task 3 5 NEW_BASE = 2 [2] num = input("Enter a non-negative integer: ") [2] num = int(num) [1] while q > 0: [1] result = str(r) + result [1] q = q // NEW_BASE [1] while q > 0 r = q % NEW_BASE result = result + str(r) q = q / NEW_BASE print(num, "in Decimal is", result, "in Binary.") [2] Total [10] Task 4 6 Input plaintext Input shift value and typecast to integer Variable set up and initialized for encrypted message Loop through plaintext Check for non-alphabet characters Correct retrieval of encrypted alphabet (non-wrap-around letters) • Retrieve alphabet value [1] • Apply shift value [1] • Retrieve encrypted alphabet [1]
3 Correct algorithm to take care of wrap-around letters Correct construction of encrypted message (non-alphabet, alphabet ) Solution alphabet_up = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" plaintext = input("Please enter your plaintext: ") shiftvalue = int(input("Please enter a shift value: ")) encrypted = "" for c in plaintext: if c in alphabet_up: encrypted += alphabet_up[(alphabet_up.find(c)+shiftvalue)%26] else: encrypted += c print("Encrypted message:", encrypted) 7 Nine lines (three lines per test case) of output Output matches stored program 8 while shiftvalue<1 or shiftvalue>25: shiftvalue = int(input("Please enter a shift value again (1-25): ")) Total [20]
Content continues in the PDF.
Related notes
- Computing o level notes Notes/Practices · 2023
- BVSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- BVSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices

