Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
22 views

Source Code

This document contains the source code for a bank management system with Python functions for various operations like account creation, deposit, withdrawal, updating customer details, showing account details etc. The code uses a CSV file to store customer records with functions to read, write, update and delete records from the file. Key functions include acc() for generating random account numbers, deposit() and withdraw() for crediting and debiting amounts, update() for modifying customer details, and show_account() to view records.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Source Code

This document contains the source code for a bank management system with Python functions for various operations like account creation, deposit, withdrawal, updating customer details, showing account details etc. The code uses a CSV file to store customer records with functions to read, write, update and delete records from the file. Key functions include acc() for generating random account numbers, deposit() and withdraw() for crediting and debiting amounts, update() for modifying customer details, and show_account() to view records.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

#SOURCE CODE OF BANK MANAGEMENT

SYSTEM
import random
import csv
def mobi():
m=1
while m==1:
mo=input("Mobile no.--")
if len(mo)==10 and mo.isdigit():
mo=int(mo)
m=2
return mo
else:
print("invalid mobile number!")
def addres():
while True:
b=input("enter your address:- ")
district=input("DISTRICT:-")
print('enter STATE below-')
state=correcter()
if len(b)!=0 and len(district)!=0 and
len(state)!=0 and district.isalpha():
break
else:
print("please enter correct
address\n")
p=1
while p==1:
pincode=input("pincode:-")
if pincode.isdigit() and
len(pincode)==6:
p=2
pincode=int(pincode)
return b,district,state,pincode
else:
print("wrong pincode")
def forget():
try:
with open('bankmanagement.csv','r') as
file:
rec=csv.reader(file)
next(rec)
acc_no=input('account number:- ')
n=0
for x in rec:
if acc_no==x[-2]:
otp()
print('\nUSERNAME:-',x[-
4],'\nPASSWORD:-',x[-3])
n=1
if n==0:
print('incorrect account
number!')
except FileNotFoundError :
print('no single account has opened!')
def otp():
otpp=0
for x in range(6):
ot=random.randint(0,9)
otpp=otpp*10+ot
print("your otp is :\t",otpp)
o=1
while o==1:
ot=input("enter otp- ")
if ot.isdigit() and int(ot)==otpp:
o=2
else:
print("invalid otp")
def acc():
import random
b=0
lst=[]
n=1
while n==1:
for x in range(12):
p=random.randint(0,9)
b+=b*10+p
n=2
print("your account number is ",b)
return b
def bank_balance():
amount=float(0)
print("available balance:-", amount)
return amount
def update():
try:
with
open("bankmanagement.csv",'r',newline='')as f:
rec=csv.reader(f)
lst=[]
ls=[]
head=next(rec)
for x in rec:
lst.append(x)
n=0
acc=input("enter account number to
be updated:- ")
if acc.isdigit():
for j in lst:
if int(acc)==int(j[-2]):
print("\nCHOICE 1-
UPDATE NAME\nCHOICE-2 :UPDATE FATHER NAME\
nCHOICE-3:UPDATE MOBILE NUMBER\nCHOICE-4 :
UPDATE EMAIL\nCHOICE-5 UPDATE ADDRESS\n ")
ch=input("enter your
choice:-")
n=1
if ch=='1':
print("your current
name is:-",j[0])
while True:
print('enter
new name below-')
b=correcter()
if len(b)!=0:
j[0]=b
break
else:
print('name
should not empty')
elif ch=='2':
print("your current
father name is:-",j[2])
while True:
print('enter
new father name below-')
f=correcter()
if len(f)!=0:
j[2]=f
break
else:
print("father name should not empty")
elif ch=='3':
print("your current
mobile number is:-",j[5])
j[5]=mobi()
elif ch=='4':
print("your current
email id is:-",j[6])
j[6]=email()
elif ch=='5':
print("your current
address is:-",j[9])
j[9]=addres()
else:
print("wrong
choice")
ls.append(j)
if n==0:
print("INVALID ACCOUNT NUMBER")
elif n==1:
with
open("bankmanagement.csv",'w',newline='')as
file:
rec1=csv.writer(file)
file.seek(0)
rec1.writerow(head)
rec1.writerows(ls)
print("data updated")
except FileNotFoundError:
print("PLEASE CREATE ATLEAST ONE
ACCOUNT")
def delete():
try:
with
open("bankmanagement.csv",'r',newline='') as f:
rec=csv.reader(f)
ch=input("enter account number to
be deleted permanent account:-")
n=0
lst=[]
field=next(rec)
if ch.isdigit():
for x in rec:
if int(ch)==int(x[-2]):
n=1
m=1
while m==1:
idd=input("enter
username:-")
passw=input("enter
password:-")
if idd==x[-4] and
passw==x[-3]:
m=0
else:
print("incorrect usename or password")
else:
lst.append(x)
if n==0:
print("INVALID ACCOUNT NUMBER")
elif n==1:
with
open("bankmanagement.csv",'w',newline='')as f:
rec=csv.writer(f)
rec.writerow(field)
rec.writerows(lst)
print("account deleted")
except FileNotFoundError:
print("PLEASE CREATE ATLEAST ONE
ACCOUNT ")
def show_account():
try:
with
open("bankmanagement.csv",'r',newline='') as f:
rec=csv.reader(f)
field=next(rec)
print("\nCHOICE-1:TO CHECK TOTAL
RECORDS\nCHOICE-2:PERSONAL ACCOUNT DETAIL\n")
ch=input("enter your choice:-")
if ch=='1':
print("Name \t Account number")
for x in rec:
print(x[0],"\t",int(x[-2]))
elif ch=='2':
idd=input("enter username:-")
password=input("enter
password:-")
n=0
for x in rec:
if idd==x[-4] and
password==x[-3]:
for k in range(14):
print(field[k],"\
t",x[k])
n=1
if n==0:
print("wrong username or
password")
else:
print("wrong choice")
except FileNotFoundError:
print("PLEASE CREATE ATLEAST ONE
ACCOUNT ")
def float_value():
n=input('>>>')
try:
money=float(n)
return money
except ValueError:
print('please enter correct value')
return float_value()
def deposit():
try:
with open("bankmanagement.csv",'r') as
f:
rec=csv.reader(f)
user=input("enter username:-")
passw=input("enter password:-")
lst=[]
n=0
field=next(rec)
for x in rec:
if user==x[-4] and passw==x[-
3]:
n=1
print("your account number
is ",x[-2])
print("available balance
",x[-1])
b=float(x[-1])
print("how much amount you
want to deposit?-")
credit_amount=float_value()
b+=credit_amount
x[-1]=b
print('\nyour account has
been credited',credit_amount,'amount')
print("avl balance ",b)
lst.append(x)
else:
lst.append(x)
if n==0:
print("incorrect username or
password")
elif n==1:
with
open("bankmanagement.csv",'w',newline='') as f:
rec=csv.writer(f)
rec.writerow(field)
rec.writerows(lst)
except FileNotFoundError:
print("Please Create Atleast one
Account")
def withdraw():
try:
with
open("bankmanagement.csv",'r',newline='') as f:
rec=csv.reader(f)
user=input("enter username:-")
passw=input("enter password:-")
lst=[]
n=0
field=next(rec)
for x in rec:
if user==x[-4] and passw==x[-
3]:
n=1
print("availabe balance
",x[-1])
print("enter amount to be
withdraw below:-")
b=float_value()
if b<=float(x[-1]):
k=float(x[-1])-b
print('\nyour account
has been debited',b,'amount')
print("avl balance ",k)
x[-1]=k
lst.append(x)
elif b>float(x[-1]):
print("insufficient
balance")
lst.append(x)
else:
lst.append(x)
if n==0:
print("incorrect username or
password")
elif n==1:
with
open("bankmanagement.csv",'w',newline='') as f:
rec=csv.writer(f)
rec.writerow(field)
rec.writerows(lst)
except FileNotFoundError:
print("Please Create Atleast One
Account")
def correcter():
while True:
n=input('>>>')
b=1
for x in n:
if x.isalpha() or x.isspace():
pass
else:
b=2
break
if b==2:
print('WRONG INPUT\nTRY AGAIN\n')
else:
return n
break
def pan_no():
n=1
while n==1:
p=input("PAN No.--").upper()
if len(p)==10 and p[0:5].isalpha() and
p[5:9].isdigit() and p[-1].isalpha():
n=2
return p
else:
print("wrong PAN No.!")
def adhar():
n=1
while n==1:
a=input("AADHAR no.--")
if len(a)==12 and a.isdigit():
n=2
a=int(a)
return a
else:
print("incorrect AADHAR no.!")
def pas_id():
m=""
for x in range(12):
w=random.randint(65,90)
m+=chr(w)
print("your username is -",m)
print("please note your username for the
future login")
while True:
k=input("create password:-.-")
if len(k)!=0:
break
else:
print("please create strong
password!")
h=1
while h==1:
b=input("confirm password:-")
if b==k:
h=2
return m,b
else:
print("password didn't match ! ")
def email():
n=2
while n==2:
em=input("email address:--")
if len(em)!=0 and em[0].isalpha() and
em[0:-10].isalnum() and (em[-10:]=="@gmail.com"
or em[-10:]=="@yahoo.com"):
n=3
return em
else:
print("wrong email !")
def openaccount():
n=0
b=0
f=0
m=0
o=0
while n==0:
print('enter applicant name')
name=correcter()
if len(name)!=0:
n=1
else:
print('*THIS FIELD IS REQUIRED!\n')
while b==0:
print('enter branch below-')
branch=correcter()
if len(branch)!=0:
b=1
else:
print("*THIS FIELD IS REQUIRED!\n")
while f==0:
print('enter father name below-')
father=correcter()
if len(father)!=0:
f=1
else:
print("*THIS FIELD IS REQUIRED!\n")
while m==0:
print('enter mother name below-')
mother=correcter()
if len(mother)!=0:
m=1
else:
print("*THIS FIELD IS REQUIRED!\n")
while o==0:
print('enter your occupation below-')
occupation=correcter()
if len(occupation)!=0:
o=1
else:
print("please enter your
occupation!\n")
mobile=mobi()
otp()
email_id=email()
pan=pan_no()
aadhar=adhar()
address=addres()
i_d,password=pas_id()
accountnum=acc()
balance=bank_balance()
print('\n---------------YOUR
DETAILS--------------\n')
ls=[name,branch,father,mother,occupation,mobile
,email_id,pan,aadhar,address,i_d,password,accou
ntnum,balance]
lst1=['name','branch','father','mother','occupa
tion','mobile','email_id','pan','aadhar','addre
ss','username','password','accountnum','bank
balance']
for x in range(14):
print(lst1[x],"\t",ls[x])
submit=input("\ndo you want to SUBMIT your
details Y/N?:-")
if submit in "yesYES":
print('''\nYour Account Has Been
Created
____________________________________\n|NAME
:-''',ls[0],'''\n|Your ACCOUNT NO.:-''',ls[-2],
'''\n|Your USERNAME :-''',ls[-4],'''\n|Your
PASSWORD :-''',ls[-3],'\
n____________________________________')
return lst1,ls
else:
return None,None
###################### Main Programme
#############################################
while True:
print('''\n\n\n\t\t\t\t WELCOME TO\n\t
\t\t\t*****IDBI BANK *****
CHOICE 1 :- ~OPEN NEW ACCOUNT~
CHOICE 2 :~ UPDATE YOUR ACCOUNT DETAILS~
CHOICE 3 :~WITHDRAW/DEPOSITE YOUR AMOUNT~
CHOICE 4:~ DELETE ACCOUNT ~
CHOICE 5:~SHOW ACCOUNT DETAILS~
CHOICE 6:~FORGET USERNAME/PASSWORD~
CHOICE 7: ~EXIT~\n''')
ch=input("ENTER YOUR CHOICE:-")
if ch=='1':
st,det=openaccount()
if st and det is not None:
try:
with
open("bankmanagement.csv",'r',newline='') as f:
n=1
except FileNotFoundError:
n=2
if n==1:
with
open("bankmanagement.csv",'a',newline='') as f:
rec=csv.writer(f)
rec.writerow(det)
elif n==2:
with
open("bankmanagement.csv",'w',newline='')as f:
rec=csv.writer(f)
rec.writerow(st)
rec.writerow(det)
else:
print("your account has not created
")
elif ch=='2':
update()
elif ch=='3':
print("CHOICE- 1 WITHDRAW\n CHOICE-2
DEPOSIT\n")
h=input("ENTER YOUR CHOICE:-")
if h=='1':
withdraw()
elif h=='2':
deposit()
else:
print("wrong choice")
elif ch=='4':
delete()
elif ch=='5':
show_account()
elif ch=='6':
forget()
elif ch=='7':
print('Thank You!')
break
else:
print("wrong choice")

You might also like