Bank Management Python Project Bonne Anne
Bank Management Python Project Bonne Anne
amounts
Admin can view a list of users to see how many users there
As you can see, it is quite basic, and you can add more
1
import pickle
importos
importpathlib
class Account :
accNo = 0
name = “
deposit=0
type = “
defcreateAccount(self):
print(“\n\n\nAccount Created”)
defshowAccount(self):
print(“Type of Account”,self.type)
print(“Balance : “,self.deposit)
2
defmodifyAccount(self):
defdepositAmount(self,amount):
self.deposit += amount
defwithdrawAmount(self,amount):
self.deposit -= amount
def report(self):
defgetAccountNo(self):
returnself.accNo
defgetAcccountHolderName(self):
return self.name
defgetAccountType(self):
returnself.type
defgetDeposit(self):
returnself.deposit
def intro():
3
print(“\t\t\t\t**********************”)
print(“\t\t\t\t**********************”)
print(“\t\t\t\tprojectworlds.in”)
input()
defwriteAccount():
account = Account()
account.createAccount()
writeAccountsFile(account)
defdisplayAll():
file = pathlib.Path(“accounts.data”)
iffile.exists ():
infile = open(„accounts.data‟,‟rb‟)
mylist = pickle.load(infile)
infile.close()
else :
4
defdisplaySp(num):
file = pathlib.Path(“accounts.data”)
iffile.exists ():
infile = open(„accounts.data‟,‟rb‟)
mylist = pickle.load(infile)
infile.close()
found = False
ifitem.accNo == num :
found = True
else :
if not found :
defdepositAndWithdraw(num1,num2):
file = pathlib.Path(“accounts.data”)
iffile.exists ():
infile = open(„accounts.data‟,‟rb‟)
mylist = pickle.load(infile)
5
infile.close()
os.remove(„accounts.data‟)
ifitem.accNo == num1 :
if num2 == 1 :
item.deposit += amount
elif num2 == 2 :
item.deposit -=amount
else :
else :
outfile = open(„newaccounts.data‟,‟wb‟)
pickle.dump(mylist, outfile)
outfile.close()
os.rename(„newaccounts.data‟, „accounts.data‟)
6
defdeleteAccount(num):
file = pathlib.Path(“accounts.data”)
iffile.exists ():
infile = open(„accounts.data‟,‟rb‟)
oldlist = pickle.load(infile)
infile.close()
newlist = []
ifitem.accNo != num :
newlist.append(item)
os.remove(„accounts.data‟)
outfile = open(„newaccounts.data‟,‟wb‟)
pickle.dump(newlist, outfile)
outfile.close()
os.rename(„newaccounts.data‟, „accounts.data‟)
defmodifyAccount(num):
file = pathlib.Path(“accounts.data”)
iffile.exists ():
infile = open(„accounts.data‟,‟rb‟)
oldlist = pickle.load(infile)
7
infile.close()
os.remove(„accounts.data‟)
ifitem.accNo == num :
outfile = open(„newaccounts.data‟,‟wb‟)
pickle.dump(oldlist, outfile)
outfile.close()
os.rename(„newaccounts.data‟, „accounts.data‟)
defwriteAccountsFile(account) :
file = pathlib.Path(“accounts.data”)
iffile.exists ():
infile = open(„accounts.data‟,‟rb‟)
oldlist = pickle.load(infile)
oldlist.append(account)
infile.close()
os.remove(„accounts.data‟)
else :
8
oldlist = [account]
outfile = open(„newaccounts.data‟,‟wb‟)
pickle.dump(oldlist, outfile)
outfile.close()
os.rename(„newaccounts.data‟, „accounts.data‟)
ch=”
num=0
intro()
whilech != 8:
#system(“cls”);
print(“\tMAIN MENU”)
print(“\t8. EXIT”)
9
print(“\tSelect Your Option (1-8) “)
ch = input()
#system(“cls”);
ifch == „1‟:
writeAccount()
elifch ==‟2′:
depositAndWithdraw(num, 1)
elifch == „3‟:
depositAndWithdraw(num, 2)
elifch == „4‟:
displaySp(num)
elifch == „5‟:
displayAll();
elifch == „6‟:
deleteAccount(num)
elifch == „7‟:
10
num = int(input(“\tEnter The account No. : “))
modifyAccount(num)
elifch == „8‟:
break
else :
print(“Invalid choice”)
11
Output
12
13
14