Overview
2023 was notable for the first appearance of a simple class-based Paper 1B scenario — a "Library" with Book objects. Average marks on Python questions dropped 6% compared with 2022.
Paper 1A Highlights
def mystery(lst):
total = 0
for x in lst:
if x > 0:
total += x
return total
Tests summing only positive values. Common mistake: forgetting the > 0 filter and returning the total of everything.
Paper 1B — Library Scenario
class Book:
def __init__(self, title, author, copies):
self.title = title
self.author = author
self.copies = copies
def borrow(self):
if self.copies > 0:
self.copies -= 1
return True
return False
Common Mistakes
- Forgetting
selfin method definitions. - Mutating class attributes instead of instance attributes.
- Returning
Nonewhere a boolean was expected.
Marker Commentary
Candidates who wrote comments explaining their logic consistently scored higher on partial-credit questions, even when the code did not fully run.
Practise this on PyForm — free
PyForm runs Python in your browser with an AI tutor trained for HKDSE. No install, no credit card.
Open PyForm →