Lesson 27 · Python Fundamentals
16 - Python Fundamentals: Simple Bank System Mini Project Tutorial
In this lesson, you will learn Python by building a simple bank system. This project is perfect for beginners. You will practice with real-world tasks like…
- CoursePython Fundamentals
- Lesson27 of 22
- Video16 min
- FormatJupyter notebook · 23 code cells
What you'll learn
Data
No separate download needed — the notebook creates or downloads everything it uses.
📓 Full notebook
Download .ipynb
Welcome to Your First Python Mini Project!#
In this lesson, you will learn Python by building a simple bank system.
This project is perfect for beginners. You will practice with real-world tasks like creating accounts, making deposits, and viewing balances.
Let us get started and see how Python can help us solve everyday problems!
1. What is a Bank System?#
A bank system lets users create accounts, keep track of balances, and perform actions like deposits and withdrawals.
With Python, you can model and manage these actions in code.
No prior experience is needed. Let us build together!
# Let us start by creating a dictionary to store our bank accounts.
accounts = {} # Each account will have an owner's name and balance
# This dictionary is empty for now.
# A quick look at our empty accounts dictionary.
print(accounts)
2. Creating a New Account#
Let us let users create new bank accounts.
We will ask for their name and a starting balance.
# Ask for user's name and starting balance.
owner = input('Enter your name: ')
balance = float(input('Enter your starting balance: '))
# Save the new account in the accounts dictionary.
accounts[owner] = {'balance': balance}
print('Account created for', owner, 'with balance $' + str(balance))
# Let us confirm that the account was saved correctly.
print(accounts)
3. Checking an Account Balance#
Let us show users their current balance.
We need to ask for their name and then look it up.
# Ask the user for their name and display their balance.
lookup_name = input('Enter your name to see your balance: ')
# Check if the user exists in our accounts.
if lookup_name in accounts:
print('Your balance is $' + str(accounts[lookup_name]['balance']))
else:
print('Sorry, we do not have an account under that name.')
# If a user tries a name that does not exist, they get a clear message.
missing_name = input('Try entering a made-up name: ')
if missing_name in accounts:
print('Your balance is $' + str(accounts[missing_name]['balance']))
else:
print('Sorry, we do not have an account under that name.')
4. Making a Deposit#
Let us allow users to add money to their account.
They will enter their name and the amount to deposit.
# Let the user deposit money into their account.
deposit_name = input('Name for deposit: ')
amount = float(input('Amount to deposit: '))
if deposit_name in accounts:
accounts[deposit_name]['balance'] += amount
print('Deposit successful! New balance is $' + str(accounts[deposit_name]['balance']))
else:
print('Sorry, that account does not exist.')
5. Withdrawing Money#
Users need to be able to take money out, too.
We will check if the user has enough money first!
# Withdraw money after checking available balance.
withdraw_name = input('Name for withdrawal: ')
withdraw_amount = float(input('Amount to withdraw: '))
if withdraw_name in accounts:
if accounts[withdraw_name]['balance'] >= withdraw_amount:
accounts[withdraw_name]['balance'] -= withdraw_amount
print('Withdrawal complete! Your new balance is $' + str(accounts[withdraw_name]['balance']))
else:
print('Sorry, you do not have enough funds.')
else:
print('Sorry, that account does not exist.')
6. Deleting an Account#
Sometimes people close their accounts.
Let us let the user remove their account from the system.
# Allow a user to delete their account.
delete_name = input('Enter your name to delete your account: ')
if delete_name in accounts:
del accounts[delete_name]
print('Account deleted. We are sorry to see you go!')
else:
print('That account was not found.')
# See all remaining accounts.
print(accounts)
7. Listing All Accounts Neatly#
Sometimes the bank wants to see all its accounts in a friendly way.
Let us use a loop to list owners and balances in a readable style.
# Print all accounts in a nice format.
if accounts:
print('Current Bank Accounts:')
for user, info in accounts.items():
print(user + ': $' + str(info['balance']))
else:
print('No accounts right now.')
8. Real-World Simulation: Multiple Actions#
Bank systems often let users choose what action they want to perform.
Next, let us build a basic action menu so users can deposit, withdraw, or view their balance.
# Present menu for deposit, withdraw, or balance.
print('Welcome to your bank!')
print('Select: 1) Deposit 2) Withdraw 3) Balance')
choice = input('Type 1, 2, or 3: ')
user = input('Enter your name: ')
if user not in accounts:
print('No account matches that name.')
else:
if choice == '1':
amt = float(input('Deposit amount: '))
accounts[user]['balance'] += amt
print('Deposit successful!')
elif choice == '2':
amt = float(input('Withdraw amount: '))
if accounts[user]['balance'] >= amt:
accounts[user]['balance'] -= amt
print('Withdrawal successful!')
else:
print('Sorry, not enough funds.')
elif choice == '3':
print('Your balance: $', accounts[user]['balance'])
else:
print('Please pick 1, 2, or 3 next time.')
bm
## 9. Mini Project Part 1: Simple Bank Loop
Let us build our very first interactive banking loop.
This will help people perform several actions until they decide to stop.
# A basic looped bank session example.
while True:
print('\nMain Menu: 1) Create 2) Deposit 3) Withdraw 4) Balance 5) Exit')
option = input('Choose (1-5): ')
if option == '1':
name = input('Your name: ')
if name in accounts:
print('Account already exists.')
else:
bal = float(input('Initial deposit: '))
accounts[name] = {'balance': bal}
print('Created account for', name)
elif option == '2':
name = input('Name: ')
if name in accounts:
amt = float(input('Deposit amount: '))
accounts[name]['balance'] += amt
print('Deposited $' + str(amt))
else:
print('No account under this name.')
elif option == '3':
name = input('Name: ')
if name in accounts:
amt = float(input('Withdraw amount: '))
if accounts[name]['balance'] >= amt:
accounts[name]['balance'] -= amt
print('Withdrew $' + str(amt))
else:
print('Not enough money.')
else:
print('No account under this name.')
elif option == '4':
name = input('Name: ')
if name in accounts:
print('Balance: $' + str(accounts[name]['balance']))
else:
print('No account under this name.')
elif option == '5':
print('Goodbye!')
break
else:
print('Please pick a number from 1 to 5.')
# After many actions, list all accounts to see results.
for user, data in accounts.items():
print(user + '\t$' + str(data['balance']))
10. Final Challenge: Try These On Your Own!#
- Open a new account with your own name.
- Make a deposit and then a withdrawal.
- Try entering a name that does not exist and handle errors.
See how many accounts you can create and manage.
Summary & Next Steps#
- You have learned how to model a bank system in Python.
- You worked with dictionaries, user input, and simple error handling.
- This mini project covers many real-world programming skills.
Keep practicing! Try adding interest, account types, or security features.
Thank You for Learning with Us!#
If you enjoyed the lesson, please:
- Like the video
- Subscribe for more beginner Python content
- Share this link with a friend
See you in the next lesson!
Found this useful?
All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.



