Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. import sys
  2.  
  3. #account balance
  4. account_balance = float(500.25)
  5.  
  6.  
  7. #functions
  8. #prints the balance
  9. def printbalance():
  10.   print("Your current balance:\n%.2f" % account_balance)
  11.  
  12. #deposits money
  13. def deposit():
  14.   global account_balance
  15.   deposit_amount=float(input("How much would you like to deposit today?\n"))
  16.   account_balance = account_balance + deposit_amount
  17.   print("Deposit was $%.2f, current balance is $%.2f" % (deposit_amount, account_balance))
  18.  
  19. #withdraws money
  20. def withdraw():
  21.   global account_balance
  22.   withdraw_amount=float(input("How much would you like to withdraw today?\n"))
  23.   if withdraw_amount > account_balance:
  24.     print('$%.2f is greater than your account balance of $%.2f' % (withdraw_amount, account_balance))
  25.   else:    
  26.     account_balance = account_balance - withdraw_amount
  27.     print("Withdrawal amount was $%.2f, current balance is $%.2f" % (withdraw_amount, account_balance))
  28.  
  29. # Users choices and if/else conditional statements
  30.  
  31. userchoice = input("What would you like to do?\n")
  32.  
  33. if userchoice == 'D':
  34.   deposit ()
  35. elif userchoice == 'W':
  36.   withdraw()
  37. elif userchoice == 'B':
  38.   printbalance()
  39. elif userchoice == 'Q':
  40.   print("Thank you for banking with us.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement