Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

ATM Program in Python using class and object:-


WAP to create ATM operation with the following operation:-

1)  Enter pin code and provide three attempt

2)  Manage Credit, Debit and Check Balance Operation

3)  Create a program using OOPS concept


class Bank:
    balance=5000
    def login(self,pin):
        if pin==1111:
            return True
        else:
            return False
    def credit(self,amt):
        self.balance+=amt
    def debit(self,amt):
        self.balance-=amt
    def display(self):
        print("Current balance is "+str(self.balance))
obj = Bank()
flag=False
for i in range(1,4):
       if obj.login(int(input("enter pin code"))):
           flag=True
           break
if flag:
  while True:
     o=input("""
             Press c for credit
             Press d for debit
             Press b for balance
             Press e for exit""") 
     if o=='c' or o=='C':
      obj.credit(int(input("enter amount for credit")))
      print("After credit total amount is ")
      obj.display()
     elif o=='d' or o=='D':
      amt=int(input("enter amount for debit"))
      if amt<obj.balance:
       obj.debit(amt)
       print("After debit total amount is ")
      else:
       print("insufficient balance")
      obj.display()
     elif o=='b' or o=='B':
      print("Total balance is ")
      obj.display()
     elif o=='e' or o=='E':
       exit(0)
else:
        print("Your pin code attempt has been completed")
     


Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post