Answer to Question #181591 in Python for Usama Ali

Question #181591

Write a python program that takes balance of a user’s account as input. It should then ask the user how much amount he\she wants to withdraw from his\her account. The program should take this amount as input and deduct from the balance. Similarly, it should ask the user how much amount he\she wants to deposit in his\her account. It should take this amount as input and add to the balance. The program shall display the new balance after amount has been withdrawn and deposited.

Note: Your program should have all necessary checks on the transactions. Display a menu to the user to let him\her choose between different available options.


1
Expert's answer
2021-04-15T02:09:16-0400
balance = 0
choice=""
while choice!="4":
    print("1. Deposit amount")
    print("2. Withdraw amount")
    print("3. Display the current balance")
    print("4. Exit")
    choice=input("Your choice: ")
    if(choice=="1"):
        #it should ask the user how much amount he\she wants to deposit in his\her account
        amount=float(input("How much amount do you want to deposit from your account?: "))
        if amount>0:
            balance+=amount
        else:
            print("\nThe amount is not a positive value.\n")
    elif(choice=="2"):
        #how much amount he\she wants to withdraw from his\her account
        amount=float(input("How much amount do you want to withdraw from your account?: "))
        if amount>0:
            if (balance-amount)>=0:
                balance-=amount
            else:
                print("\nNot enough money for bank account withdrawal.\n")
        else:
            print("\nThe amount is not a positive value.\n")
        
    elif(choice=="3"):
        print("The current balance: "+str(balance))
    elif(choice=="4"):
        pass
    else:
        print("\nSelect correct menu item.\n")
    

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