Documente Academic
Documente Profesional
Documente Cultură
CERTIFICATE
1
Online Banking System
ACKNOWLEDGEMENT
2
Online Banking System
Introduction to Python
Python is a powerful multi-purpose programming language created by Guido van
Rossum.
The Python interpreter and the extensive standard library are freely available in
source or binary form for all major platforms from the Python Web
site, https://www.python.org/, and may be freely distributed. The same site also
contains distributions of and pointers to many free third party Python modules,
programs and tools, and additional documentation.
The Python interpreter is easily extended with new functions and data types
implemented in C or C++ (or other languages callable from C). Python is also
suitable as an extension language for customizable applications.
3
Online Banking System
One of the popular approach to solve a programming problem is by creating
objects. This is known as Object-Oriented Programming (OOP).
attributes
behavior
Person is an object,
The concept of OOP in Python focuses on creating reusable code. This concept is
also known as DRY (Don't Repeat Yourself).
Class
Object
4
Online Banking System
Methods
Methods are functions defined inside the body of a class. They are used to define
the behaviors of an object.
Inheritance
Inheritance is a way of creating new class for using details of existing class without
modifying it. The newly formed class is a derived class (or child class). Similarly,
the existing class is a base class (or parent class).
Encapsulation
Using OOP in Python, we can restrict access to methods and variables. This
prevent data from direct modification which is called encapsulation. In Python, we
denote private attribute using underscore as prefix i.e single “ _ “ or double “ __“.
Polymorphism
Polymorphism is an ability (in OOP) to use common interface for multiple form
(data types).
Suppose, we need to color a shape, there are multiple shape option (rectangle,
square, circle). However we could use same method to color any shape. This
concept is called Polymorphism.
When these exceptions occur, it causes the current process to stop and passes it to
the calling process until it is handled. If not handled, our program will c
A critical operation which can raise exception is placed inside the try clause and
the code that handles exception is written in except clause.
5
Online Banking System
Python File I/O
Since, random access memory (RAM) is volatile which loses its data when
computer is turned off, we use files for future use of the data.
When we want to read from or write to a file we need to open it first. When we are
done, it needs to be closed, so that resources that are tied with the file are freed.
1. Open a file
2. Read or write (perform operation)
3. Close the file
6
Online Banking System
Hardware and Software Specification
Python 3.7
7
Online Banking System
Data Dictionary
Cust.dat
S.No. Name Description
1. ano Begins with 1001, generated automatically
2 Cname Should be only character
3 Addr Can have alpha numeric value
4 Phno Should have 10 digits
5 Doo Current date
6 atype Should accept “S” and “C”
Trans.dat
S.No Name Description
1 ano Should exits in cust.dat
2 atype Retrieved from cust.dat
3 ir Should be calculated based on the type of account
4 tamt Should be accepted from the user
5 cbal Should be updating the current balance
6 tdate Current date
Gen_cust.log
Begins with 1001 and generates the customer number automatically, when a
new customer opens an account in the bank.
8
Online Banking System
PROJECT DESCRIPTION
Objective:
-->Develop a system that can replace the manual bank managing system.
-->Develop a database which stores customer details & account details.
-->Give reliable search facility for the customer s.
-->Create an easy to understand user friendly environment.
-->Attractive user interfaces to navigate through the system for the customers.
Files :
There are five separate files that are being maintained.
• The cust.dat stores the details of the customer.
• The Trans.dat file stores the details of customers such as customer name,
account no., account type and balance.
• The Gen_cust.log to store the last member number to generate the next last
customer number.
Inputs:
• Addition, Modification and Deletion of Customer details.
• Transaction like withdrawl and deposit.
Outputs:
• Displaying the details of all the Customers.
• Transaction done in the bank on daily bases.
9
Online Banking System
SOURCE CODE
import pickle,os,datetime
Cfile="cust.dat"
Tfile="trans.dat"
#validation functions
def numerics(z):
while True:
try:
mn = int(z)
except ValueError:
print("Invalid Input.")
else:
break
return mn
def balance(z):
while True:
try:
mn = int(z)
10
Online Banking System
if mn<2000:
return z
except ValueError:
print("Invalid Input.")
else:
break
return mn
def string(z):
while True:
try:
if z.isalpha() == True:
return z
else:
raise ImportError
except ImportError:
print('Invalid Entry')
11
Online Banking System
def fixed(z, length):
while True:
try:
if len(z) != length:
raise ZeroDivisionError
else:
return z
except ZeroDivisionError:
print("Invalid Input")
def acct_type(z):
while True:
try:
if z in ('S','C'):
return z
else:
raise ImportError
except ImportError:
print('Invalid Choice')
12
Online Banking System
#Generator to generate account no. automatically
def counter(n):
while True:
yield n
n=n+1
gf.write(str(n))
try:
s=gf.read()
s=int(s)
except ValueError:
pass
ct=counter(s)
class cust:
def __init__(self,ano=0,cname='',addr='',phno=0,atype='',bal=0):
self.ano=ano
self.cname=cname
self.addr=addr
self.phno=phno
self.atype=atype
13
Online Banking System
self.bal=bal
self.doo=datetime.date.today()
def enter(self):
self.ano=ct.next()
self.doo=datetime.date.today()
def show(self):
print("\nCustomer Details\n")
print("Account No.:",self.ano)
def modify_cust(self):
if not os.path.isfile(Cfile):
14
Online Banking System
print(Cfile,"does not exist")
else:
cob=open(Cfile,'rb')
tob=open("tempc.dat","ab+")
fg=0
try:
while True:
ct=pickle.load(cob)
if (ct.ano==tcode):
print("\nCustomer details\n")
ct.show()
pickle.dump(ct,tob)
fg=1
else:
pickle.dump(ct,tob)
except EOFError:
pass
if (fg==0):
15
Online Banking System
print("Account Number",tcode,"not found")
tob.close()
cob.close()
os.remove("cust.dat")
os.rename("tempc.dat","cust.dat")
def delete_cust(self):
if not os.path.isfile(Cfile):
else:
cob=open(Cfile,'rb')
tob=open("tempd.dat","ab+")
ct=cust()
fg=0
try:
while True:
ct=pickle.load(cob)
if (ct.ano!=tcode):
pickle.dump(ct,tob)
16
Online Banking System
fg=1
except EOFError:
pass
if (fg==0):
tob.close()
cob.close()
os.remove("cust.dat")
os.rename("tempd.dat","cust.dat")
def valid_ano(d):
cob=open(Cfile,'rb')
ct=cust()
fg=0
try:
while True:
ct=pickle.load(cob)
d=int(d)
if (ct.ano==d):
fg=1
17
Online Banking System
break
cob.close()
except EOFError:
pass
if (fg==1):
return d
else:
return d
class trans(cust):
def __init__(self,ano=0,atype='',ir=0,tamt=0):
self.ano=ano
self.atype=atype
self.ir=ir
self.tamt=tamt
self.tdate=datetime.date.today()
self.ttype=''
def Withdrawl(self):
tof=open("tempf.dat","ab+")
18
Online Banking System
cob=open(Cfile,'ab+')
tob=open(Tfile,'wb+')
ct=cust()
bt=trans()
fg=0
d=int(d)
try:
while True:
ct=pickle.load(cob)
if (ct.ano==d):
bt.ttype="Withdraw"
bt.ano=ct.ano
bt.atype=ct.atype
diff=ct.bal-amt
print("Difference=",diff)
if (diff>2000):
ct.bal=diff
fg=1
#break
else:
19
Online Banking System
print("Minimum balance below 2000")
diff=ct.bal-amt
ct.bal=diff
bt.tdate=datetime.date.today()
bt.tamt=amt
if (ct.atype=='S'):
bt.ir=0.12
else:
bt.ir=0.15
pickle.dump(bt,tob)
pickle.dump(ct,tof)
print("Balance=",diff)
except EOFError:
pass
except ValueError:
pass
tob.close()
cob.close()
tof.close()
os.remove("cust.dat")
20
Online Banking System
os.rename("tempf.dat","cust.dat")
def deposit(self):
tof=open("tempf.dat","ab+")
cob=open(Cfile,'ab+')
tob=open(Tfile,'wb')
ct=cust()
bt=trans()
fg=0
d=int(d)
try:
while True:
ct=pickle.load(cob)
if (ct.ano==d):
bt.ttype="Deposit"
bt.ano=ct.ano
bt.atype=ct.atype
diff=ct.bal+amt
#print "Amount=",diff
21
Online Banking System
ct.bal=diff
bt.tdate=str(datetime.date.today())
bt.tamt=amt
if (ct.atype=='S'):
bt.ir=0.12
else:
bt.ir=0.15
pickle.dump(bt,tob)
pickle.dump(ct,tof)
print("Balance=",diff)
except EOFError:
pass
except ValueError:
pass
tob.close()
cob.close()
tof.close()
os.remove("cust.dat")
os.rename("tempf.dat","cust.dat")
def bal_enq(self):
print("\nBalance Enquiry\n")
22
Online Banking System
tob=open(Tfile,'rb')
cob=open(Cfile,'rb')
ct=cust()
ts=trans()
fg=0
d=int(d)
try:
while True:
ts=pickle.load(tob)
ct=pickle.load(cob)
break
else:
except EOFError:
pass
tob.close()
23
Online Banking System
def show_trans(self):
tob=open(Tfile,'rb')
ts=trans()
try:
while True:
ts=pickle.load(tob)
print("\nAccount No.:",ts.ano)
except EOFError:
pass
tob.close()
def daily_report(self):
try:
tos=open(Tfile,'rb')
ts=trans()
while True:
ts=pickle.load(tos)
d=str(ts.tdate)
yy=int(d[0:4])
mm=int(d[5:7])
dd=int(d[8:11])
ts.show_trans()
else:
except EOFError:
pass
tos.close()
def monthly_report(self):
try:
tos=open(Tfile,'rb')
ts=trans()
ts=pickle.load(tos)
d=str(ts.tdate)
yy=str(d[0:4]).strip()
mm=str(d[5:7]).strip()
dd=str(d[8:10]).strip()
if ((yy==y) or (mm==m)):
ts.show_trans()
else:
except EOFError:
pass
tos.close()
def main():
ce=cust()
te=trans()
while True:
ch=0
print("\nBanking Project\n")
print("Main Menu")
26
Online Banking System
print(" 1. Customer \n 2. Transaction \n 3. Reports\n 4.Exit")
if ch==1:
ch1=0
if ch1==1:
cob=open(Cfile,"ab+")
ca=cust()
try:
ca.enter()
pickle.dump(ca,cob)
except EOFError:
pass
cob.close()
elif ch1==2:
ce.modify_cust()
elif ch1==3:
ce.delete_cust()
27
Online Banking System
elif ch==2:
ch2=0
if ch2==1:
te.Withdrawl()
elif ch2==2:
te.deposit()
elif ch2==3:
te.bal_enq()
elif ch2==4:
te.show_trans()
elif ch==3:
ch3=0
print("\n REPORTS\n")
if ch3==1:
try:
28
Online Banking System
cos=open(Cfile,'rb')
cs=cust()
while True:
cs=pickle.load(cos)
print(cs.ano,"||\t\t",cs.cname,"||\t\t",cs.phno,"||\t\t ",cs.addr,"||\t\t
",cs.bal,"||\t",cs.doo,"||\t ",cs.atype)
except EOFError:
pass
cos.close()
elif ch3==2:
te.daily_report()
elif ch3==3:
te.monthly_report()
elif ch3==4:
main()
elif ch==4:
break
main()
29
Online Banking System
OUTPUT SCREENS
30
Online Banking System
31
Online Banking System
32
Online Banking System
33
Online Banking System
34
Online Banking System
35
Online Banking System
36
Online Banking System
BIBLIOGRAPHY
1. Computer Science Textbook
By Sumita Arora
2. www.python.org/docs
3. https://www.javatpoint.com/python-tutorial
4. https://www.programiz.com/python-programming/tutorial
5. https://www.tutorialspoint.com/python3/index.htm
37
Online Banking System