Python Program using classes and objects to deposit and withdraw money in a Bank Account

 

Python Program using classes and objects to deposit and withdraw money in a Bank Account

Problem Definition:

Write a Python program using classes and objects to deposit and withdraw money in a Bank_Account. This is just a demonstration program.

Video Tutorial

Source code of Python Program using classes and objects to deposit and withdraw money in a Bank Account

class Bank:
    def __init__(self):
        self.balance = 0
        print ("The account is created")
        
    def deposit(self):
        amount = float(input("Enter the amount to be deposit: "))
        self.balance = self.balance + amount
        print ("The deposit is successful and the balance in the account is %f" % self.balance)
    
    def withdraw(self):
        amount = float(input("Enter the amount to withdraw: "))
        if (self.balance >= amount):
            self.balance = self.balance - amount
            print ("The withdraw is successful and the balance is %f" % self.balance)
        else:
            print ('Insuficient Balance')
    
    def enquiry(self):
        print ("Balance in the account is %f" % self.balance)
        

acc = Bank()
acc.deposit()
acc.withdraw()
acc.enquiry()

Output of Program is:

The account is created

Enter the amount to be deposit: 10000

The deposit is successful and the balance in the account is 10000.000000

Enter the amount to withdraw: 5000

The withdraw is successful and the balance is 5000.000000

Balance in the account is 5000.000000

Summary:

This article discusses, how to write a Python program to deposit and withdraw money from a Bank Account. Subscribe to our YouTube channel for more videos and like the Facebook page for regular updates.

1 thought on “Python Program using classes and objects to deposit and withdraw money in a Bank Account”

  1. i want to search for the account number previously added and deposit or withdraw money from the balance of the corresponding object ,how can i do it??

Leave a Comment

Your email address will not be published. Required fields are marked *

Welcome to VTUPulse.com


Computer Graphics and Image Processing Mini Projects -> Click Here

Download Final Year Project -> Click Here

This will close in 12 seconds