Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. account_balance = float(500.25)
  2. deposit_amount = float(0)
  3. withdraw_amount = float(0)
  4. def printbalance(account_balance):
  5.     balance = account_balance
  6.     return account_balance
  7. def deposit (deposit_amount, account_balance):
  8.   deposit_amount = float(input('How much would you like to deposit today?'))
  9.   account_balance = account_balance + deposit_amount
  10.   print ('Deposit was $' + '%.2f' % deposit_amount +', current balance is $' + '%.2f' % account_balance)
  11.   return deposit_amount, account_balance
  12. def withdraw (withdraw_amount, account_balance):
  13.   withdraw_amount = float(input('How much would you like to withdraw today?'))
  14.   if withdraw_amount > account_balance:
  15.     print ('$' + '%.2f' % withdraw_amount + 'is greater than your account balance of $' + '%.2f' % account_balance)
  16.   elif withdraw_amount <= account_balance:
  17.     account_balance = account_balance-withdraw_amount
  18.     print('Withdrawal amount was $' + '%.2f' % withdraw_amount + ', current balance is $' + '%.2f' % account_balance)
  19.     return withdraw_amount, account_balance
  20. userchoice = ('M')
  21. while userchoice != 'Q':
  22.   userchoice = input ("What would you like to do?\nEnter B for Balance, D for Deposit, or W to Withdraw. Select Q to Quit")
  23.   if (userchoice == 'B'):
  24.     print ('your current balance:')
  25.     print(printbalance(account_balance))
  26.   elif (userchoice == 'D'):
  27.     deposit(deposit_amount, account_balance)
  28.   elif (userchoice == 'W'):
  29.     withdraw(withdraw_amount, account_balance)
  30.   elif (userchoice == 'Q'):
  31.     print ('Thank you for banking with us.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement