Time: 0:00
This is a mutation and copying bugs bug
Assignment does not copy, a shallow copy still shares its contents, and mutating methods return None.
Python's round() uses banker's rounding: an exact .5 goes to the nearest even number, so 2.5 becomes 2 and 3.5 becomes 4. It avoids a statistical upward drift when you round many numbers, but it is not the rule taught in school. For school-style rounding of positive numbers, add 0.5 and truncate with int(). For money or exact rules, use the decimal module with ROUND_HALF_UP. If a rounding bug only shows on every other .5, this is the cause.
The pattern behind it: mutation and copying bugs.
Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.
<iframe src="https://trybughunt.com/embed/f3bca78e-e9b8-4e28-9d71-4a354d325795" title="Debugging challenge: Grade rounding cheats students out of half a mark" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/f3bca78e-e9b8-4e28-9d71-4a354d325795">BugHunt</a></p>