Mini project — pocket money tracker

Kabir gets ₹50 at the start of the week. He spends on a pencil and a snack, then checks what is left for the piggy bank. This chapter is not a new idea — it is the previous chapters standing together: variables, a list of spends, a loop that subtracts, and a decision about saving. That is how real programs look: small ideas composed.

Pocket-money pouch

Combine skills into a small tool.

You will be able to

  • Combine variables, lists, loops and if
  • Print a clear money report a parent could check
  • Change one spend and re-run without rewriting the whole story

Plan on paper, then translate

Write three sentences: start with 50; for each spend, subtract; if anything remains, save it. Those sentences become three parts of the program. If you cannot say it in the kitchen, you cannot code it yet.

Keep spends in a list so next week you add one number, not a new variable spend4. The loop does not care how many shops Kabir visited.

Running total

left = start copies the opening amount. Each loop turn does left = left - rupees. This pattern — an accumulator — appears in cricket run rates, lab inventories and bank ledgers.

Print after each subtraction if you want a receipt. Print once at the end if you only need the piggy-bank decision. Both are valid; receipts are easier to debug.

What you just learned, in one map

print showed facts. Variables named them. Arithmetic combined them. if chose a sentence. for repeated a subtraction. lists held many spends. You now have enough Python to automate a stall bill, a game score, or a class inventory — slowly, with tests, one print at a time.

  • Name every input (start, spends).
  • Loop the collection, do not copy-paste lines.
  • End with a human sentence (Save / Empty), not a bare number.

Words that matter

Accumulator
A variable that updates inside a loop, like left.
Composition
Building a program from smaller skills you already have.

Common mistakes

Avoid: Subtracting from start each time instead of from left.

Do this: Keep a running left so each spend stacks.

Avoid: Hard-coding the final 18 rupees.

Do this: Let the loop compute remaining so new spends still work.

Example program — Kabir's week

Change a spend and watch remaining update. Then add a third spend to the list.

Python sandboxlesson://workspace
console

Edit the example, press Run, then Build if you want a compile check.

build

Press Build to compile.

Your turn — Your tracker

Start with 100. Spend 25 then 10. Print a line containing Save and the remaining 65.

Python sandboxlesson://workspace
console

Edit the example, press Run, then Build if you want a compile check.

build

Press Build to compile.

Self-assessment

Check your understanding before you mark the lesson complete.

1. Why is a list of spends useful here?
2. An accumulator is…
3. This project is mainly…

Progress is stored in a browser cookie on this device.