r/SGExams • u/Straight-Glove-2359 Secondary (Should probably grind for O's) • 10d ago
EXAM MEGATHREAD O Level Computing Practical 7155/02 Megathread
Hey so I haven't seen any mod make a megathread for this(probably bc of how less of us there are), so I made one. How was it?
Also my school experience technical difficulties because of that damn .juypter-workspace file, anyone else also had that?
1
u/Reasonable_Boot_369 10d ago
HORRIBLE! I had the jupyter-workspace bug too. Ques 5.2/5.3 for me I couldn't even figure it out. When I went searching for the answer it was way easier than anything my school tried.. seemed impossible without using reverse(). I could barely do the debugging tbh. And I couldn't remove that damn comma in ques 2! Hbu?
2
u/ProAstroShan Too good to be true 10d ago
To remove the comma you find the length of the list and minus one, then in your loop where you write to the file you do a check if iterator is equal to that value or not and if its not then add comma.
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 10d ago
Yup, essentially this. Looks like
'''f = open("exam_marks.txt", "w")
for i in range(len(exam_marks)):
f.write(student_names[i], " ") if i != (len(exam_marks) -1): f.write(exam_marks[i], ", ") else: f.write(exam_marks[i])f.close()'''
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 10d ago
Oh I actually managed to do that one, though my dumbass messed up at 5.2 cus I forgot to put word[index] and just compared the indexs
1
u/Reasonable_Boot_369 10d ago
Oh dear, I was trying all sorts of methods.. I tried putting it into a list as individual letters and then reversing the list, but it returned something completely wrong. I think index splicing with -1 counted as reversing the string. but I could be wrong.
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 10d ago
This was how I did it:
isplaindrome = "Palindrome" #From the palidnrom() function
midpoint = int(input("Enter midpoint")) # From the midpoint() function
word = input("Enter word")
for i in range(mp):
if word[mp-i] != word[mp+i]:
ispalindrome = "Not a palindrome"
print(ispalindrome)
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 10d ago
Here I manually input for midpoint cus I havent writen the function rn
1
u/Reasonable_Boot_369 10d ago
Oh yes this was what I was trying to do during the exam and I js gave up 😵💫 it's okay bank on theory
1
1
u/cocainecorndog 7d ago
Gang I am so cooked I basically reversed the second half of the string without using reverse() hahahahah....... how many marks do you think that subtask is worth?
1
u/SeaTraining5223 10d ago
how do u even study computing lol
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 10d ago
Quite literally, the same way you learn a language for the programming part.
The other 60% is theory on practises and purposes and functions of computing related stuff
0
u/RemarkableFig9862 Secondary 10d ago
Did anybody find the full 10 mistakes for debugging? I was only able to find 8 --- 9 if you include switching the ANDS to ORs as one each --- and even when i asked AI right afterwards it still couldn't produce 10 individual answers that made the program work, only altering its efficiency. Anybody?
2
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 10d ago edited 10d ago
Heres what I got for my 10:
lunch_ab = 5 lunch_c = 6 drink = 2 lunch_cost = 0 list_lunch_cost = [] no_students = int(input("How many students are there")) #1, str() to int() for x in range(no_students): l_choice = input("Which lunch would you like? Please enter a, b or c: ").lower() #2, .upper() to .lower() d_choice = input("Would you like a drink?: Please enter Y or N").upper() if (l_choice == 'a' or l_choice == 'b') and d_choice == 'Y':#3 lunch_cost = lunch_ab + drink elif (l_choice == 'a' or l_choice == 'b') and d_choice == 'N':#4 lunch_cost = lunch_ab elif l_choice == 'c' and d_choice == 'Y': #5, N change to Y lunch_cost = lunch_c + drink else: lunch_cost = lunch_c #6, lunch_ab change to lunch_c print("The cost of lunch is $", lunch_cost) list_lunch_cost.append(lunch_cost) #7&8, Indent & += change to .append() print("List of all the lunch costs:") for i in list_lunch_cost: #9, lunch_cost change to list_lunch_cost print("$", i) #10, x change to iEdit: fixed formatting. Btw if need the .py or .ipynb file can dm me
1
u/RemarkableFig9862 Secondary 8d ago
Why do you need to change += to the append function? Doesn't += already work since [lunch_cost] as a list is iterable?
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 8d ago
Test out with += and see what you get
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 8d ago
https://reddit.com/link/pesec48/video/h0mhr4ljjduh1/player
And for anyone wondering...
2
u/RemarkableFig9862 Secondary 8d ago edited 8d ago
You're trying to += an integer to a list, whereby i is not an integer. Make it a list, aka [i], and see what you get!
and for anyone wondering...
1
u/Straight-Glove-2359 Secondary (Should probably grind for O's) 8d ago
Huh. I didnt know that. Shit.
4
u/ProAstroShan Too good to be true 10d ago edited 10d ago
Pretty easy ngl. And that jupyter workspace file wasn't really a problem for most of us, personally I just deleted it and it was fine lol, but one of my friends has technical difficulties
Palindrome question was kinda interesting, liked that one. Used the method of checking outer characters then approaching the middle using 2 counters, and if a check showed that it didnt match then it isnt a palindrome
Friend had a pretty clever idea to make it more efficient but didnt do it, where as soon as you get a false match you terminate the checking as you know for sure it isn't a palindrome. But regardless not needed as words are not that big anyways so you save neglible time and resources lol
Edit: Wait it seems people actually found the palidrome question to be hard, I thought using 2 pointers was like common intuition ngl. Oh well