Good Comments Explain Why

# Bad: explains what the code already says
x = x + 1   # add 1 to x

# Good: explains intent
x = x + 1   # compensate for 0-based indexing

Docstrings for Functions

def grade(score):
    """Return letter grade for 0-100 score."""
    ...

When to Delete Comments

HKDSE Marking Note

Comments are not formally awarded marks, but markers see cleaner work when you explain non-obvious decisions โ€” and partial credit is easier to award when intent is clear.

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 โ†’