Hi,
This is my first off-platform project, please take a look! Thanks to others who posted their projects here, I needed some help when I got stuck a few times and your posts helped.
**1. Initializing savings and checking account values.**
checking_balance = 0
savings_balance = 0
**2. Create a function to check the Balance**
def check_balance(account_type, checking_balance, savings_balance):
if account_type == "checking":
balance = checking_balance
elif account_type == "savings":
balance = savings_balance
else:
return "Unsuccessful, please enter \"checking\" or \"savings\""
balance_statement = "Your " + account_type + " balance is $" + str(balance)+"."
return balance_statement
**3. Calling and Printing the check_balance() function for Checking Account**
print(check_balance("checking", checking_balance, savings_balance))
Your checking balance is $0.
**4. Calling and Printing the check_balance() function for Savings Account**
print(check_balance("savings", checking_balance, savings_balance))
Your savings balance is $0.
**5. Create a function to make a deposit**
def make_deposit(account_type, amount, checking_balance, savings_balance):
deposit_status = " "
if amount > 0:
deposit_status += 'successful'
if account_type == "checking":
checking_balance += amount
elif account_type == "savings":
savings_balance += amount
else:
deposit_status += 'Unsuccessful, please enter \"checking\" or \"savings\"'
else:
deposit_status += "unsuccessful, please enter an amount greather than zero"
deposit_statement = 'Deposit of $' + str(amount) + ' to your ' + account_type + ' account was ' + deposit_status
print(deposit_statement)
return checking_balance, savings_balance
**6. Call deposit function and make a savings deposit**
checking_balance, savings_balance = make_deposit("savings", 10, checking_balance, savings_balance)
Deposit of $10 to your savings account was successful
**7. Print savings balance call after making a savings deposit**
check_balance("savings", checking_balance, savings_balance)
'Your savings balance is $10.'
**8. Call deposit function and make a checking deposit**
checking_balance, savings_balance = make_deposit("checking", 200, checking_balance, savings_balance)
Deposit of $200 to your checking account was successful
**9. Print checking balance call after making a checking deposit**
check_balance("checking", checking_balance, savings_balance)
'Your checking balance is $200.'
**10. Create a function to make a withdrawal**
def make_withdrawal(account_type, amount, checking_balance, savings_balance):
withdrawal_status = ""
fail = "unsuccessful, please enter amount less than balance"
if account_type == "savings":
if amount > savings_balance:
withdrawal_status = fail
else:
savings_balance -= amount
withdrawal_status += "successful"
elif account_type == "checking":
if amount > checking_balance:
withdrawal_status = fail
else:
checking_balance -= amount
withdrawal_status += "successful"
else:
withdrawal_status += 'Unsuccessful, please enter \"checking\" or \"savings\"'
withdrawal_statement = "Withdrawal of amount " + str(amount) + " from your " + account_type + " was " + withdrawal_status
print(withdrawal_statement)
return savings_balance, checking_balance
**11. Call withdrawal function and make a savings withdrawal**
savings_balance, checking_balance = make_withdrawal("savings", 11, checking_balance, savings_balance)
Withdrawal of amount 11 from your savings was unsuccessful, please enter amount less than balance
**12. Print savings balance call, after making a savings withdrawal**
check_balance("savings", checking_balance, savings_balance)
'Your savings balance is $10.'
**13. Call withdrawal function and make a checking withdrawal**
savings_balance, checking_balance = make_withdrawal("checking", 170, checking_balance, savings_balance)
Withdrawal of amount 170 from your checking was successful
**14. Print checking balance call, after making a checking withdrawal**
check_balance("checking", checking_balance, savings_balance)
'Your checking balance is $30.'
**15. Create a function to make a transfer between accounts**
def acc_transfer(acc_from, acc_to, amount, checking_balance, savings_balance):
transaction_status = ""
trans_error = "unsuccessful, please enter amount less than "
if acc_from == "savings" and acc_to == "checking":
if amount > savings_balance:
transaction_status = trans_error + str(savings_balance)
else:
savings_balance -= amount
checking_balance += amount
transaction_status += "successful"
elif acc_from == "checking" and acc_to == "savings":
if amount > checking_balance:
transaction_status = trans_error + str(checking_balance)
else:
checking_balance -= amount
savings_balance += amount
transaction_status = "successful"
else:
transaction_status += "unsuccessful, please enter \"checking\" or \"savings\""
transaction_statement = "Transfer of " + str(amount) + " from your " + acc_from + " to " + acc_to + " account was " + transaction_status
print(transaction_statement)
return savings_balance, checking_balance
**16. Call transfer function and make a checking to savings transfer**
savings_balance, checking_balance = acc_transfer("checking", "savings", 40, checking_balance, savings_balance)
Transfer of 40 from your checking to savings account was unsuccessful, please enter amount less than 30
**17. Print checking balance after making a checking to savings transfer**
check_balance("checking", checking_balance, savings_balance)
'Your checking balance is $30.'
**18. Print savings balance after making a checking to savings transfer**
check_balance("savings", checking_balance, savings_balance)
'Your savings balance is $10.'
**19. Call transfer function and make a savings to checking transfer**
savings_balance, checking_balance = acc_transfer("savings", "checking", 5, checking_balance, savings_balance)
Transfer of 5 from your savings to checking account was successful
**20. Print checking balance after making a savings to checking transfer**
check_balance("checking", checking_balance, savings_balance)
'Your checking balance is $35.'
**21. Print saving balance after making a savings to checking transfer**
check_balance("savings", checking_balance, savings_balance)
'Your savings balance is $5.'