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.

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 ("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 successfull and balance is %f" % self.balance)
        else:
            print ('Insuficient Balance')
    
    def enquiry(self):
        print ("Balance in the acount 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
Deposit is successful and the balance in the account is 10000.000000
Enter the amount to withdraw: 5000
The withdraw is successfull and balance is 5000.000000
Balance in the acount is 5000.000000

Video Tutorial

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

READ  How to use dictionaries in Python

Leave a Comment

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

error: Content is protected !!