▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
Mini project: bank account system
Accounts, deposits, withdrawals and statements.
🎬 Video version coming soon — read it now
Let's combine everything from this course into a small banking system: classes, methods, properties, inheritance, special methods and dataclasses.
Requirements
- Accounts have a holder, an account number and a balance
- Deposit and withdraw, with validation
- Every action is recorded as a transaction
- A savings account can't go below a ₹1,000 minimum balance and earns interest
- Print a readable statement
The code
Design choices to notice
- Transaction is a frozen dataclass: history can't be edited after the fact, just like a real bank.
- balance is a read-only property. The only way to change it is through deposit and withdraw, which validate and record.
- SavingsAccount overrides just one small method,
can_withdraw.withdrawitself is inherited unchanged. Small override points like this keep inheritance simple. _next_numberis a class attribute, so every new account gets the next number.__repr__usestype(self).__name__, so it prints the right class name for both account types.
Expected result
The ₹4,000 withdrawal is blocked, because it would leave about ₹513, below the ₹1,000 minimum. The final balance is ₹4,513.13 after one month's interest.
Challenges
- Add a
CurrentAccountwith an overdraft limit of ₹10,000. - Add
transfer(to_account, amount)that withdraws from one account and deposits to another. - Save all accounts to a JSON file and load them back (from the previous course).
- Write the OOP interview answers from the previous lesson using this code as your examples.
What you learned in this course
- Classes, objects, __init__ and self; methods and special methods
- Inheritance, super() and composition
- Encapsulation with @property; dataclasses
- Designing classes with AI, and answering OOP interview questions
Next course: Python Meets AI. You'll use everything so far to call AI models from Python and build your own AI tools.
In one line
You built a small banking system with validated, recorded transactions and a savings account that inherits and overrides just what it needs.
Share with a friend