Program to store the details multiple employees

0 votes

Can you please share a code to develop a bank project program to store the details multiple employees ??

Feb 12 in Python by Junaid
32 views

1 answer to this question.

0 votes
import random
class Bank:
      def __init__(self):
            self.dic={}
            self.acctno=random.randrange(10000,100000,1)
      def newAccount(self):
            print("Enter your name")
            self.name=input()
            self.dic[self.name]={}
            print("Enter the initial deposite ")
            self.initAmount=int(input())
            self.dic[self.name][self.acctno]=self.initAmount
      def display(self):
            print("Account creation has been successful. Your account number is ",self.acctno)
            print()
            print()
      def existing(self,nam,actno):
            self.nam=nam
            self.actno=actno
            if self.dic[self.nam][self.actno] >=0:
                  print("Authentication Successfull")
                  print()
                  return True
            else:
                  print("Authentication Failed")
                  print()
                  return False
      def withdrawal(self,nam,actno):
            print("Enter a withdrawal amount ")
            self.wit=int(input())
            self.nam=nam
            self.actno=actno
            if self.dic[self.nam][self.actno]>=self.wit:
                  self.dic[self.nam][self.actno]=self.dic[self.nam][self.actno]-self.wit
                  print("Withdrawal was successful.")
                  print("Available balance : ",self.dic[self.nam][self.actno])
                  print()
            else:
                  print("Insufficient balance ")
                  print()
      def addamount(self,nam,actno):
            self.nam=nam
            self.actno=actno
            print("Enter the amount you want to deposite ")
            self.add=int(input())
            print()
            self.dic[self.nam][self.actno]=self.dic[self.nam][self.actno]+self.add
            print("Deposite was successful.")
            print("Available balance ",self.dic[self.nam][self.actno])
      def displaybalance(self,nam,actno):
            self.nam=nam
            self.actno=actno
            print("Available balance ",self.dic[self.nam][self.actno])
            
                  
bank=Bank()

while True:
      print("Enter 1 to create a new account ")
      print("Enter 2 to access Existing account ")
      print("Enter 3 to exit ")
      userchoice=int(input())
      if userchoice==1:
            newaccount=bank.newAccount()
            bank.display()
      elif userchoice==2:
            print("Enter your name ")
            nam=input()
            print("Enter your account number")
            actno=int(input())
            boolean=bank.existing(nam,actno)
            if boolean:
                  while True:
                        print("Enter 1 to withdraw ")
                        print("Enter 2 to deposite ")
                        print("Enter 3 to display available balance ")
                        print("Enter 4 to go back to the previous menu ")
                        userinput=int(input())
                        if userinput==1:
                              bank.withdrawal(nam,actno)
                        elif userinput==2:
                              bank.addamount(nam,actno)
                        elif userinput==3:
                              bank.displaybalance(nam,actno)
                        elif userinput==4:
                              break
            else:
                  continue
                  
      elif userchoice==3:
            exit()
answered Feb 12 by Omkar
• 67,620 points

Related Questions In Python

+1 vote
3 answers

How to run the Python program forever?

you can also do the old fashioned ...READ MORE

answered Jun 10 in Python by brianno
640 views
0 votes
1 answer

how to check the syntax of python program without running the program?

Yes, it is possible to check the ...READ MORE

answered Jun 27 in Python by Arvind
• 2,960 points
37 views
+1 vote
2 answers

How to resize the image canvas to maintain a square aspect ratio

down voteacceptedUsing OpenCVYou can use resize() in OpenCV to ...READ MORE

answered Apr 4, 2018 in Python by charlie_brown
• 7,720 points
194 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 280 views
+4 votes
6 answers
0 votes
1 answer

Python program to read the excel file which contains more than 65K records

Hi @Rashmi! I read your code and there ...READ MORE

answered Feb 8 in Python by Omkar
• 67,620 points
46 views
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2 in Python by Omkar
• 67,620 points
34 views