Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- #account balance
- account_balance = float(500.25)
- #functions
- #prints the balance
- def printbalance():
- print("Your current balance:\n%.2f" % account_balance)
- #deposits money
- def deposit():
- global account_balance
- deposit_amount=float(input("How much would you like to deposit today?\n"))
- account_balance = account_balance + deposit_amount
- print("Deposit was $%.2f, current balance is $%.2f" % (deposit_amount, account_balance))
- #withdraws money
- def withdraw():
- global account_balance
- withdraw_amount=float(input("How much would you like to withdraw today?\n"))
- if withdraw_amount > account_balance:
- print('$%.2f is greater than your account balance of $%.2f' % (withdraw_amount, account_balance))
- else:
- account_balance = account_balance - withdraw_amount
- print("Withdrawal amount was $%.2f, current balance is $%.2f" % (withdraw_amount, account_balance))
- # Users choices and if/else conditional statements
- userchoice = input("What would you like to do?\n")
- if userchoice == 'D':
- deposit ()
- elif userchoice == 'W':
- withdraw()
- elif userchoice == 'B':
- printbalance()
- elif userchoice == 'Q':
- print("Thank you for banking with us.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement