Bank Management- Python Project Class 12
Source Code:
#https://cbsepython.in print("****BANK TRANSACTION****") #creating database import mysql.connector mydb=mysql.connector.connect (host="localhost",user="root", passwd="admin") mycursor=mydb.cursor() mycursor.execute("create database if not exists bank") mycursor.execute("use bank") #creating required tables mycursor.execute("create table if not exists bank_master(acno char(4) primary key,name varchar(30),city char(20),mobileno char(10),balance int(6))") mycursor.execute("create table if not exists banktrans(acno char (4),amount int(6),dot date,ttype char(1),foreign key (acno) references bank_master(acno))") mydb.commit() while(True): print("1=Create account") print("2=Deposit money") print("3=Withdraw money") print("4=Display account") print("5=Exit") ch=int(input("Enter your choice:")) #PROCEDURE FOR CREATING A NEW ACCOUNT OF THE APPLICANT if(ch==1): print("All information prompted are mandatory to be filled") acno=str(input("Enter account number:")) name=input("Enter name(limit 35 characters):") city=str(input("Enter city name:")) mn=str(input("Enter mobile no.:")) balance=0 mycursor.execute("insert into bank_master values('"+acno+"','"+name+"','"+city+"','"+mn+"','"+str(balance)+"')") mydb.commit() print("Account is successfully created!!!") #PROCEDURE FOR UPDATIONG DETAILS AFTER THE DEPOSITION OF MONEY BY THE APPLICANT elif(ch==2): acno=str(input("Enter account number:")) dp=int(input("Enter amount to be deposited:")) dot=str(input("Enter date of Transaction: YYYY-MM-DD ")) ttype="d" mycursor.execute("insert into banktrans values('"+acno+"','"+str(dp)+"','"+dot+"','"+ttype+"')") mycursor.execute("update bank_master set balance=balance+'"+str(dp)+"' where acno='"+acno+"'") mydb.commit() print("money has been deposited successully!!!") #PROCEDURE FOR UPDATING THE DETAILS OF ACCOUNT AFTER THE WITHDRAWL OF MONEY BY THE APPLICANT elif(ch==3): acno=str(input("Enter account number:")) wd=int(input("Enter amount to be withdrawn:")) dot=str(input("enter date of transaction: YYYY-MM-DD ")) ttype="w" mycursor.execute("insert into banktrans values('"+acno+"','"+str(wd)+"','"+dot+"','"+ttype+"')") mycursor.execute("update bank_master set balance=balance-'"+str(wd)+"' where acno='"+acno+"'") mydb.commit() #PROCEDURE FOR DISPLAYING THE ACCOUNT OF THE ACCOUNT HOLDER AFTER HE/SHE ENTERS HIS/HER ACCOUNT NUMBER elif(ch==4): acno=str(input("Enter account number:")) mycursor.execute("select * from bank_master where acno='"+acno+"'") for i in mycursor: print(i) else: break
Output:
****BANK TRANSACTION**** 1=Create account 2=Deposit money 3=Withdraw money 4=Display account 5=Exit Enter your choice:1 All information prompted are mandatory to be filled Enter account number:1001 Enter name(limit 35 characters):"Jitendra Singh" Enter city name:"New Delhi" Enter mobile no.:1234567890 Account is successfully created!!!
Enter your choice:2 Enter account number:1001 Enter amount to be deposited:5000 Enter date of Transaction: YYYY-MM-DD 2021-10-10 money has been deposited successully!!!
Enter your choice:3 Enter account number:1001 Enter amount to be withdrawn:1000 enter date of transaction: YYYY-MM-DD 2021-10-11
Enter your choice:4 Enter account number:1001 ('1001', '"Jitendra Singh"', '"New Delhi"', '1234567890', 4000) 1=Create account 2=Deposit money 3=Withdraw money 4=Display account 5=Exit
You should also check:
-
Important questions for Practical Viva
-
Class 12 Practical File for Term 2 Practical Examination
-
More Python Projects

A passionate blogger and author of this website having 10+ years of experience in education sector as a CS faculty. His expertise in Python, C++, Java, MySQL, MongoDB and Artificial intelligence. […]