AI Agents by HandAll problemsAbout

All problems › Python drill · medium · ~5 min

d11 · Format a money total

rounding

Solve it in your browser →

d11 · Format a money total (~5 min)

Numbers, missing values, time. Edit drills.py. Standard library only; no model calls, no API key.

def format_total(items):

items: [{"unit_price": float or str, "qty": int}, ...].

Return the total as "$1,234.50": exact cents (3 x 0.1 is $0.30), rounded half up (2.675 -> $2.68, 0.125 -> $0.13), with thousands separators. No items -> "$0.00".

Failure messages are enough to go on, so leave the tests unread until you submit.

Starter code and hidden tests open in the editor. Nothing to install.