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 13, 2019 in Python by Junaid
2,153 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 13, 2019 by Omkar
• 69,220 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, 2019 in Python by brianno
21,291 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, 2019 in Python by Arvind
• 3,050 points
5,712 views
+1 vote
1 answer
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,042 views
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 9, 2019 in Python by Omkar
• 69,220 points
1,326 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, 2019 in Python by Omkar
• 69,220 points
2,856 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP