The Four Rules
- Variables and functions โ
snake_case. - Classes โ
PascalCase. - Constants โ
ALL_CAPS. - Private โ start with
_.
Names That Describe Intent
# Bad d = 86400 # seconds in a day? x = get(u) # Good SECONDS_PER_DAY = 86400 user = get_user_by_id(user_id)
Avoid Abbreviations
num_studentsbeatsnstu.total_pricebeatstp.
Loop Counters Are OK Short
i, j, k are fine for numeric loops. For list iteration, prefer for student in students.
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 โ