Você está na página 1de 26

COMPUTER SCIENCE

INVESTIGATORY
PROJECT

BANK MANAGEMENT
SYSTEM
Certificate

This is to certify that Mr. Gaurav Kumar,


student of class XII-C, has successfully
completed the below given project under
the heading ‘Bank Management System’
during the academic session 2019-2020
under the guidance of Mrs. B. Sharadha.

Signature of Principal

Signature of External Examiner

Signature of Subject Teacher


Acknowledgement

I would like to express my immense gratitude


to my computer teacher Mrs. Sharadha , for
the help and guidance she provided for
completing the investigatory project.
I also thank my parents who gave their ideas
and inputs in making this Project. Most of all I
thank our school management, for providing us
the facilities and opportunity to do this project.
Lastly, I would like to thank my school mates
who have helped me finish this project.
Their support made this project fruitful.
- Gaurav Kumar
Table of Contents

Introduction 5
Modules Used 6
Source Code 7
Output Screen 20
Bibliography 26
Introduction
This project is designed to Manage Bank
Accounts in Python programming language.
The title of this project is
Bank Management System.
In this project, an account can be created,
amount can be deposited or withdrawn,
Balance enquiry and details of all account
holders present in the bank database can be
accessed by the user.
Records are made with following details:
Name, Type of Account and Deposit Amount.
Modules Used
random
Returns a random number based on a given range.

mysql.connector
Connects to a MySQL Database through Python.
Source Code
import mysql.connector as sql
import random

mycon= sql.connect(host='localhost',user=
'Gaurav',passwd='root',database= 'bank')
if mycon.is_connected()== False:
print("Error connecting to MySQL
ahffdjdjd database")

cursor= mycon.cursor()

def createAccount():
accNo= random.randint(10000000,99999999)
name = input("\nEnter the Account
aaaaaaaaaaaaaaaaaaaaHolder's name : ")
acctype = input("Enter the type of
aaaaaaaaaaaaaaaaaaaaaAccount [C/S] : ")
acctype = acctype.upper()
deposit = int(input("Enter The Initial
amount(>=500 for Saving and >=1000 for
Current:"))
print("\n\n\nAccount Created")
print('\n\nAccount Number:',accNo)
print('\n\n')
data= "Insert into data
values({},'{}','{}',{})".format(accNo,name,ac
ctype,deposit)
cursor.execute(data)
mycon.commit()

def acnames():
allnames= "select Name from data"
cursor.execute(allnames)
listofnames= cursor.fetchall()
if listofnames:
for i in range(len(listofnames)):
list_tup= listofnames[i]
for j in list_tup :
print(list_tup[0])

else:
print("No Records to display !")

def displayAll():
alldet= "select * from data"
cursor.execute(alldet)
details= cursor.fetchall()
if details:
for i in range(len(details)):
det_tup = details[i]
for j in range(len(det_tup)):
print(det_tup[j], end =' ')
print(end='\n')
else :
print("No Records to display !")
def displayBal(num):
accbalstr= "select Balance from data
where Acc_Num={}".format(num)
cursor.execute(accbalstr)
bal= cursor.fetchone()
if bal:
balinit= bal[0]
print("\nYour Current Account Balance
aaaaaaaaaaaaaaaaais",balinit)
else:
print("\nProvided Account Details
aaaaaaaaaaaaaaaaaIncorrect !")

def depositAndWithdraw(accnum,num):
accbalstr= "select Balance from data
where Acc_Num={}".format(accnum)
cursor.execute(accbalstr)
bal= cursor.fetchone()
if bal:
balinit= bal[0]
if num == 1:
amount = int(input("Enter the
aaaaaaaaaaaaaaaaaaaaaaamount to deposit : "))
depstr= "update data set
aaaaaaaaaaaaaaaaa Balance=Balance + {} where
aaaaaaaaaaaaAcc_Num =
aaaaaaaaaaaaaaaaaaaa{}".format(amount,accnum)
cursor.execute(depstr)
mycon.commit()
print("\nYour Account Balance has
been updated Successfully !")

elif num == 2:
amount = int(input("Enter the
aaaaaaaaaaaaaaaaaaaaaamount to withdraw : "))
if amount > balinit :
print("\nYou don't have
aaaaaaaaaaaaaaaaa enough balance !")
else:
withstr= "update data set
aaaaaaaaaaaaaaaaa Balance= Balance - {}
aaaaaaaaaaaaaaaaa where Acc_Num =
aaaaaaaaaaaaaaaaa {}".format(amount,accnum)
cursor.execute(withstr)
mycon.commit()
print("\nAmount has been
aaaaaaaaaaaaaaaaa withdrawn and Balance
aaaaaaaaaaaaaaaaa has been updated
aaaaaaaaaaaaaaaaa Successfully !")

else:
print("\nAccount Not Found !!!")

def deleteAccount(num):

accbalstr= "select Balance from data


aaaaaaaaaaaaaaaawhere Acc_Num={}".format(num)
cursor.execute(accbalstr)
bal= cursor.fetchone()
if bal:
delstr= "delete from data where
aaaaaaaaaaaaaaaaaAcc_Num = {}".format(num)
cursor.execute(delstr)
mycon.commit()
print("\nAccount Closed !!!")
else :
print("\nAccount Not Found !!!")

def modifyAccount(num):
cha= ''
accbalstr= "select Balance from data
aaaaaaaaaaaaaaaawhere Acc_Num={}".format(num)
cursor.execute(accbalstr)
bal= cursor.fetchone()
if bal:
while not (cha == '1' or cha == '2'
aaaaaaaaaaaaaaaaa or cha == '3'):
print("\nTo Modify Your Account
aaaaaaaaaaaaaaaDetails such as Name, Type,
aaaaaaaaaaaaaaaDeposit... Enter the
aaaaaaaaaaaaaaarespective number for each
aaaaaaaaaaaaaaaoption :")
print("\n1. Name\n2. Account Type
aaaaaaaaaaaaaaa[C/S]\n3. Deposit Amount\n")
cha= input("Enter 1,2 or 3 :")
if cha == '1' :
nname= input("\nEnter New
aaaaaaaaaaaaaaaaa Name:")
nnamestr= "update data set
aaaaaaaaaaaaaaaaa Name = '{}' where
aaaaaaaaaaaaaaaaa Acc_Num =
aaaaaaaaaaaaaaaaa {}".format(nname,num)
cursor.execute(nnamestr)
mycon.commit()
print("\nName has been
aaaaaaaaaaaaaaaaa Updated !!")
elif cha =='2' :
ntype=''
while not (ntype== 'S' or
aaaaaaaaaaaaaaaaa ntype == 'C'):

print('C - Current\nS –
aaaaaaaaaaaaaaaaa Saving')
ntype= input("\nEnter New
aaaaaaaaaaaaaaaaa Type [C or S]:")
ntype= ntype.upper()
if (ntype == 'S' or ntype
aaaaaaaaaaaaaaaaa == 'C'):
ntypestr= "update
aaaaaaaaaaaaaaaaa data set Type='{}'
aaaaaaaaaaaaaaaaa where Acc_Num =
aaaaaaaaaaaaaaaaa {}".format(ntype,num)

cursor.execute(ntypestr)
mycon.commit()
print("\nAccount Type
aaaaaaaaaaaaaaaaa has been Updated !!")
else:
print("Wrong
aaaaaaaaaaaaaaaaa Character !!")
elif cha == '3':
ndep= input("\nEnter Deposit
aaaaaaaaaaaaaaaaa b Amount:")
ndepstr= "update data set
aaaaaaaaaaaaaaaaaBalance = {} where Acc_Num =
aaaaaaaaaaaaaaaaa{}".format(ndep,num)
cursor.execute(ndepstr)
mycon.commit()
print("\nDeposit Amount has
aaaaaaaaaaaaaaaaa been Updated !!")
else:
print("\n\nInvalid Choice
aaaaaaaaaaaaaaaaa !!!")
else:
print("\n\nAccount Not Found !!!")
#START of the Main Program

ch=''
while ch != 9:

print("\n\n\t---MAIN MENU---\n")
print("1. NEW ACCOUNT")
print("2. DEPOSIT AMOUNT")
print("3. WITHDRAW AMOUNT")
print("4. BALANCE ENQUIRY")
print("5. ALL ACCOUNT HOLDER LIST")
print("6. CLOSE AN ACCOUNT")
print("7. MODIFY AN ACCOUNT")
print("8. VIEW COMPLETE BANK DETAILS OF
aaaaaaaaaaaaaaALL ACCOUNT HOLDERS")
print("9. EXIT\n")

ch = input("Select Your Option (1-8):")


if ch == '1' :
createAccount()
elif ch =='2':
num = int(input("\nEnter the Account
aaaaaaaaaaaaaaaaaNumber : "))
depositAndWithdraw(num, 1)
elif ch == '3':
num = int(input("\nEnter the Account
aaaaaaaaaaaaaaaaaNumber : "))
depositAndWithdraw(num, 2)
elif ch == '4':
num = int(input("\nEnter the Account
aaaaaaaaaaaaaaaaaNumber : "))
displayBal(num)
elif ch == '5':
print('\n')
acnames()
elif ch == '6':
num = int(input("\nEnter the Account
aaaaaaaaaaaaaaaaaNumber : "))
deleteAccount(num)
elif ch == '7':
num = int(input("\nEnter the Account
aaaaaaaaaaaaaaaaaNumber : "))
modifyAccount(num)
elif ch == '8':
print('\n')
displayAll()
elif ch == '9':
print("\nThanks for using our Bank
aaaaaaaaaaaaaaaa Management System !!!\n\n")
break
else :
print("\n\nInvalid choice !!!")

#END of the Program

//****************//
Output
Main Menu
Create Account

Deposit
Withdraw

Balance Enquiry
Account Holders List

Close an Account
Modify an Account
All Bank Holders Details
Bibliography
www.google.com

www.W3school.com

Computer Science With Python, Sumita Arora

*****

Você também pode gostar