Your first Python project on Mac: a receipt checker
Build something small enough to verify yourself: a program that adds three purchases and checks its own total. All names and amounts below are invented practice data.
What you will practise
You will use a list, a loop, a function and integer arithmetic. This example stores money in cents so the basic exercise avoids decimal rounding surprises. It uses only Python's standard language features, with no account, API key or package installation.
Codemonkey AI: macOS 12 or later, Apple silicon and Intel. Website Direct edition: $10 USD once. Check the product page for the release and download details.
The app is optional for running this example. Use an existing Python 3 environment, or follow the official Python instructions for macOS. In Codemonkey AI, use an available Python practice or project workspace; controls can differ by app version.
Read the code, then run it
Download receipt-checker.py. Open and read it before running it. The script does not read personal files, connect to the network or change your system.
items = [("Notebook", 450), ("Pen", 125), ("Folder", 225)]
def total_cents(rows):
total = 0
for name, cents in rows:
total += cents
return total
total = total_cents(items)
print(f"Items: {len(items)}")
print(f"Total: {total // 100}.{total % 100:02d}")
assert total == 800In a terminal opened to the file's folder, run python3 receipt-checker.py. This is a standard Python example; successful execution here is not a benchmark of the Mac app.
Check the result
Items: 3
Total: 8.00450 + 125 + 225 = 800 cents. The assertion checks that arithmetic. If it fails after an edit, work out the expected total before changing the assertion.
| Change | Expected result | Lesson |
|---|---|---|
| Add a 200-cent item | 4 items and 10.00; update the expected total after calculating it | How a list changes the calculation |
| Use an empty list | 0 items and 0.00 | Why the total starts at zero |
| Rename an item | The total stays the same | Which part of each row affects the sum |
Use an AI tutor to explain, then test
Ask: “Explain why the function returns zero for an empty list. Give me one hint about adding quantities, without writing the whole solution.” Predict the result of your next change before running it.
If you connect an external model provider in Codemonkey AI, its charges and data handling are separate from the app purchase. A compatible local model requires its own resources. Keep practice inputs non-sensitive.
Next, add quantities, validate that each amount is an integer, or split the formatting into another function. Use the learn-to-code practice plan and review Codemonkey AI's lessons and requirements.