Answer to Question #186520 in Python for Rania

Question #186520

Create a Python class named BankAccount which represents a bank account with the following attributes: numAccount, name (name of the owner of the account) and balance. 1. Create the constructor (__init__ method) 2. Create a method deposit() which manages payments. 3. Create a withdrawal() method that handles withdrawals. 4. Create a display() method that displays the details of the account 5. Create an instance of the class BankAccount and call the three methods defined.


1
Expert's answer
2021-04-28T06:16:13-0400
class Bank_Account:

    def __init__(self):

        self.balance=0

        print("Hello!!! Welcome to the Deposit & Withdrawal Machine")
    def deposit(self):

        amount=float(input("Enter amount to be Deposited: "))

        self.balance += amount

        print("\n Amount Deposited:",amount)

    def withdraw(self)
        amount = float(input("Enter amount to be Withdrawn: "))

        if self.balance>=amount:

            self.balance-=amount

            print("\n You Withdrew:", amount)

        else:

            print("\n Insufficient balance  ")

     def display(self):

        print("\n Net Available Balance=",self.balance)

s.deposit()
s.withdraw()
s.display()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS