Making A Bank Account Program In Python

bank account program in python
Table of Contents

Today we will make a bank account program in python it will be like bank management system with python the user will be able to withdraw, deposit and check their balance this is a basic bank account program in python.

The program is created with python without any libraries I have used functional programming to create this program I hope you will like this and you should try to create it on your own if you can’t I will give code below.

If you are intrested in more projects like this than you can check out my projects that I have created at coderzway projects.

Bank account program in python

I hope you have knowledge of python basics and you have python installed on your machine if you don’t have python installed you can go to the python website and download – download python and remember to check add python to path while installing.

1. Create python file

Now first you need to create python file with .py extension you can go to any folder and create a python file and you need to open this file in a text editor I use vs code you can use any editor you can download vs code from here – download vs code.

2. Copy and paste

Now you have created the file now this is the code of the bank account program you can paste this code for bank account python program.

				
					# Python bank program made by coderzway 

# Press w for withdrawing money
# Press d for depositing money
# Press b for showing your balance
# Press q for showing quiting the program

is_logined = False
is_quit = False

user = {
    'name': '',
    'balance': 0
}

def create_user():
    name = input('Enter your name: ')
    user['name'] = name
    global is_logined
    is_logined = True

def withdraw_money():
    try:
        w_amount = int(input('How much money you want to withdraw : '))
        if w_amount > user['balance']:
            print('Your account does not have that much money')
        elif w_amount == 0:
            print('What you are fooling around here')
        else:
            user['balance'] = user['balance'] - w_amount
            print(f'{w_amount} has been withrawn from your account your total balance left is {user["balance"]}')
            print('')
    except:
        print('Please enter a number')            

def deposit_money():
    try:
        d_amount = int(input('How much money you want to deposit : '))
        user['balance'] = user['balance'] + d_amount
        print(f'{d_amount} has been deposited to your account your total balance is {user["balance"]}')
        print('')
    except:
        print('Please enter a number')    

def show_balance():
    print(f'Your balance is {user["balance"]}')
    print('')

def start():
    while is_quit == False:
        if is_logined == False:
            print('Create your account : ')
            create_user()
        else :
            print(f'Welcome to bank {user["name"]} what you want to do ')
            res = input('Press w for withdraw and d to deposit and b to show your balance : ')
            if res == 'w':
                withdraw_money()
            elif res == 'd':
                deposit_money()
            elif res == 'b':
                show_balance()
            elif res == 'help':
                print('Press w for withdrawing money')
                print('Press d for depositing money')
                print('Press b for showing your balance')
                print('Press q for showing quiting the program')
            elif res == 'q':
                break
            else:
                print('Enter a correct value from given type help for commands')

start()
				
			

3. Run the file

So now you have to run this file you can run the file through command prompt by typing python filename.py enter the name of your python file this will run the program.

Output

				
					Create your account :
Enter your name: coderzway
Welcome to bank coderzway what you want to do
Press w for withdraw and d to deposit and b to show your balance : d
How much money you want to deposit : 1200
1200 has been deposited to your account your total balance is 1200

Welcome to bank coderzway what you want to do
Press w for withdraw and d to deposit and b to show your balance : b
Your balance is 1200

Welcome to bank coderzway what you want to do
Press w for withdraw and d to deposit and b to show your balance : w
How much money you want to withdraw : 100
100 has been withrawn from your account your total balance left is 1100

Welcome to bank coderzway what you want to do
Press w for withdraw and d to deposit and b to show your balance :

				
			

How this works

The program is made using functions the main function is the start functions which runs on the start of the program the start function will run untill the is_quit is true then there we have the withdraw, deposit and balance functions.

So this was a simple bank account program in python if you have created it own your own then great if you can’t copy and paste the above code you can add more functionality to this program.

Thank you for reading I hope you found what you were looking for you can browse our website you will find awesome coding guides and projects.

Summary

These was the project on how to make a bank account program in python if you loved this do share it with your friends and family and do subscribe to our newsletter.

If you want to know more about python than read this article why learn python in 2021 This will help you to understand python language more.

Thank you for reading Have a nice day 🙂

Share This Post
Share on facebook
Share on twitter
Share on email
Share on whatsapp

Leave a Reply

Subscribe To Our Newsletter

Get updates and learn from the best

Latest Guides & Articles