Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- #account balance
- account_balance = float(500.25)
- def helper(operation, amount):
- global account_balance
- print('%s was $%.2f, current balance is $%.2f' %(operation, amount, account_balance))
- #printbalance function
- def printbalance():
- global account_balance
- print('Your current balance: \n%.2f' % account_balance)
- #deposit function
- def deposit():
- global account_balance
- deposit_amount = float(input("How much would you like to deposit today?\n"))
- account_balance += deposit_amount
- print('Deposit was $%.2f, current balance is $%.2f' %(deposit_amount, account_balance))
- #withdraw function
- def withdraw():
- global account_balance
- while True:
- withdrawal_amount = float(input("How much would you like to withdraw today?\n"))
- if(withdrawal_amount > account_balance):
- print('$%.2f is greater than your account balance of $%.2f' %(withdrawal_amount, account_balance))
- else:
- account_balance -= withdrawal_amount
- print('Withdrawal was $%.2f, current balance is $%.2f' %(withdrawal_amount, account_balance))
- break
- #User Input goes here, use if/else conditional statement to call function based on user input
- userchoice = input("What would you like to do?\n")
- if (userchoice == 'D'):
- deposit()
- elif (userchoice == 'W'):
- withdraw()
- elif (userchoice == 'B'):
- printbalance()
- else:
- print('Thank you for banking with us.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement