Bank teller project

Hello everyone! Follow my bank teller project.

checking_balance = 0
savings_balance = 0
def check_balance ( account_type, checking_balance, savings_balance):
    
    if account_type == "savings":

        balance = savings_balance
       
    elif account_type == "checking":
        
        balance = checking_balance 
        
    else:
        return acc_error
    
    balance_statement = " Your "   + account_type + " balance is " + str(balance )
    return balance_statement
    
    
print(check_balance("checking", checking_balance, savings_balance))
 Your checking balance is 0
print (check_balance("checking", checking_balance, savings_balance))
 Your checking balance is 0

  

  File "<ipython-input-5-e43865519cd4>", line 4
    Define a function named `make_deposit()` that accepts four parameters `account_type`, `amount`, `checking_balance` and `savings_balance`. The `amount` represents the amount to be deposited.
           ^
SyntaxError: invalid syntax
 def make_deposit(account_type, amount, checking_balance, savings_balance):
    
    deposit_status = ""
    
    if amount > 0:
        
        if account_type == "savings" :
            savings_balance += amount
            deposit_status = "successful"
            
        elif account_type == "checking":
            checking_balance += amount
            deposit_status = "successful"
        
        else:
            deposit_status = acc_error
      
    else:
        deposit_status= "unsuccessful, please enter an amount greater than 0"
    
    deposit_statement = "Deposit of " +str(amount) + " to your " + account_type + " account was " + deposit_status + "."
    
    print (deposit_statement)
    
    return savings_balance, checking_balance


        
    
savings_balance, checking_balance  = make_deposit("savings", 10, checking_balance, savings_balance) 


Deposit of 10 to your savings account was successful.
print(check_balance("savings", checking_balance, savings_balance))
 Your savings balance is 10
savings_balance, checking_balance  = make_deposit("checking", 200, checking_balance, savings_balance )
Deposit of 200 to your checking account was successful.
print (check_balance("checking", checking_balance, savings_balance))
 Your checking balance is 200
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:
            savings_balance -= amount
            withdrawal_status = "successuful"
            
        else:
            withdrawal_status = fail
        
    
    elif account_type == "checking":
        
        if amount <= checking_balance:
            checking_balance -= amount
            withdrawal_status = "successuful"
        
        else:
            withdrawal_status = fail
    
    
    else:
        withdrawal_status = "unsuccessful, please enter \"checking\" or \"savings\""
        
    withdrawal_statement = "Withdrawal of " + str(amount) +  "  dollars from your " + account_type + " was " + withdrawal_status
    
    print(withdrawal_statement)
    
    return savings_balance, checking_balance
checking_balance,savings_balance  = make_withdrawal("savings", 11,checking_balance, savings_balance)
Withdrawal of 11  dollars from your savings was successuful
print(check_balance("savings",checking_balance,savings_balance  ))
 Your savings balance is 10
checking_balance, savings_balance =  make_withdrawal( "checking", 170, checking_balance, savings_balance)
Withdrawal of 170  dollars from your checking was Unsuccessful, please enter amount less than balance
print(check_balance("savings", checking_balance, savings_balance))
 Your savings balance is 10
def acc_transfer (acc_from, acc_to, amount, checking_balance, savings_balance):
    
    trans_status =""
    
    trans_error = "unsuccessuful, please enter  amount less than"
    
    if acc_from == "savings" and acc_to == "checking" :
        
        if amount <= savings_balance:
            savings_balance -= amount
            checking_balance += amount
            withdrawal_status = "successuful"
            
        else:
            trans_status  = trans_error + str(savings_balance)
            
    
    elif acc_from =="checking" and acc_to == "savings":
        
        if amount <= checking_balance:
            checking_balance -= amount
            savings_balance += amount
            withdrawal_status = "successuful"
            
        else:
            trans_status = trans_error + str(checking_balance)
            
           
    
    else:
        trans_status = "unsuccessful, please enter \"checking\" or \"savings\""
    
    trans_statement = "transfer of " +str(amount) +" from your " + acc_from + " to your "+ acc_to + " account was" + trans_status
    
    print(trans_statement)
    
    return savings_balance, checking_balance
    
savings_balance, checking_balance = acc_transfer("checking", "savings", 40, checking_balance, savings_balance)
transfer of 40 from your checking to your savings account wasunsuccessuful, please enter  amount less than19
print(check_balance("checking", checking_balance , savings_balance)) 
 Your checking balance is 19
print(check_balance("savings", checking_balance , savings_balance))
 Your savings balance is 10
checking_balance, savings_balance = acc_transfer("savings", "checking", 5, checking_balance,savings_balance)
print(check_balance("checking", checking_balance, savings_balance))
 Your checking balance is 19
print(check_balance("savings", checking_balance, savings_balance))
 Your savings balance is 10


1 Like

Hello @tera7483730904 and welcome to the forums

Well done :grinning:

If you want a challenge try to use the read and write commands to make it so you can close the program and open it back up to were you left off.

I just started playing around with those and they are fun to use.

2 Likes