0% found this document useful (0 votes)
12 views3 pages

Bank Management System Code Example

The document contains a Python code for a Bank Management System that allows users to create accounts, deposit and withdraw money, check balances, and view all accounts. It utilizes a text file to store account data in JSON format. The system provides a simple command-line interface for user interactions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Bank Management System Code Example

The document contains a Python code for a Bank Management System that allows users to create accounts, deposit and withdraw money, check balances, and view all accounts. It utilizes a text file to store account data in JSON format. The system provides a simple command-line interface for user interactions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Bank Management System Code

import os, json

FILE="bank_data.txt"

def load():

if not [Link](FILE): return {}

with open(FILE,"r") as f: return [Link](f)

def save(data):

with open(FILE,"w") as f: [Link](data,f)

def create():

data=load()

acc=input("Enter Account Number: ")

if acc in data:

print("Account already exists")

return

name=input("Enter Name: ")

bal=float(input("Enter Initial Balance: "))

data[acc]={"name":name,"balance":bal}

save(data)

print("Account Created")

def deposit():

data=load()

acc=input("Enter Account Number: ")

if acc not in data:

print("Account not found")

return

amt=float(input("Enter Amount: "))

data[acc]["balance"]+=amt
save(data)

print("Amount Deposited")

def withdraw():

data=load()

acc=input("Enter Account Number: ")

if acc not in data:

print("Account not found")

return

amt=float(input("Enter Amount: "))

if amt>data[acc]["balance"]:

print("Insufficient Balance")

return

data[acc]["balance"]-=amt

save(data)

print("Amount Withdrawn")

def check():

data=load()

acc=input("Enter Account Number: ")

if acc not in data:

print("Account not found")

return

print("Name:",data[acc]["name"])

print("Balance:",data[acc]["balance"])

def view_all():

data=load()

for acc,v in [Link]():

print(acc,v["name"],v["balance"])
while True:

print("\n1 Create Account\n2 Deposit\n3 Withdraw\n4 Check Balance\n5 View All Accounts\n6
Exit")

ch=input("Enter Choice: ")

if ch=="1": create()

elif ch=="2": deposit()

elif ch=="3": withdraw()

elif ch=="4": check()

elif ch=="5": view_all()

elif ch=="6": break

else: print("Invalid Choice")

You might also like