Skip to content
IT Vizag
← Objects & Classes

▶ 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

Lesson 10 of 10 · 3 min read

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

🔒 Code example: sign up free (above) to unlock it.

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. withdraw itself is inherited unchanged. Small override points like this keep inheritance simple.
  • _next_number is a class attribute, so every new account gets the next number.
  • __repr__ uses type(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

  1. Add a CurrentAccount with an overdraft limit of ₹10,000.
  2. Add transfer(to_account, amount) that withdraws from one account and deposits to another.
  3. Save all accounts to a JSON file and load them back (from the previous course).
  4. 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.

Saved on this device. Sign in to keep progress everywhere.

Share with a friend