Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import sys
  2.  
  3. #account balance
  4. account_balance = float(500.25)
  5.  
  6. def helper(operation, amount):
  7. global account_balance
  8. print('%s was $%.2f, current balance is $%.2f' %(operation, amount, account_balance))
  9.  
  10. #printbalance function
  11. def printbalance():
  12. global account_balance
  13. print('Your current balance: \n%.2f' % account_balance)
  14.  
  15. #deposit function
  16. def deposit():
  17. global account_balance
  18. deposit_amount = float(input("How much would you like to deposit today?\n"))
  19. account_balance += deposit_amount
  20. print('Deposit was $%.2f, current balance is $%.2f' %(deposit_amount, account_balance))
  21.  
  22.  
  23. #withdraw function
  24. def withdraw():
  25. global account_balance
  26. while True:
  27. withdrawal_amount = float(input("How much would you like to withdraw today?\n"))
  28. if(withdrawal_amount > account_balance):
  29. print('$%.2f is greater than your account balance of $%.2f' %(withdrawal_amount, account_balance))
  30. else:
  31. account_balance -= withdrawal_amount
  32. print('Withdrawal was $%.2f, current balance is $%.2f' %(withdrawal_amount, account_balance))
  33. break
  34.  
  35. #User Input goes here, use if/else conditional statement to call function based on user input
  36.  
  37. userchoice = input("What would you like to do?\n")
  38.  
  39. if (userchoice == 'D'):
  40. deposit()
  41. elif (userchoice == 'W'):
  42. withdraw()
  43. elif (userchoice == 'B'):
  44. printbalance()
  45. else:
  46. print('Thank you for banking with us.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement