First Project done : Bank Teller

#!/usr/bin/env python
# coding: utf-8

### Bank Teller Project

###Initialization of the variables

checking_balance = 0
savings_balance = 0

### Definition of the check_balance function

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 "Unsuccessful, please enter \"checking\" or \"savings\""
    balance_statement = "Your " + account_type + " balance is " + str(balance)      
    return balance_statement

### test of the check_balance function

print(check_balance("checking",checking_balance, savings_balance))

print(check_balance("savings",checking_balance,savings_balance))

### definition of the make_deposit function

def make_deposit(account_type,amount,checking_balance,savings_balance):
    deposit_status = str()
    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 = "Unsuccessful, please enter \"checking\" or \"savings\""
    else:    
        deposit_status = "unsuccessful, please enter an amount greater than 0"
    deposit_statement = "Deposit of " + str(amount) + " to your " + str(account_type) + " account was " + deposit_status +"."
    print(deposit_statement)
    return savings_balance, checking_balance

### Tests of the make_deposit function

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

print(check_balance("savings", checking_balance, savings_balance))

savings_balance, checking_balance = make_deposit("checking", 200, checking_balance, savings_balance)

print(check_balance("checking", checking_balance, savings_balance))

### Definition of the make_withdrawal function

def make_withdrawal(account_type, amount, checking_balance, savings_balance):
    withdrawal_status = str()
    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 " + str(amount) + " from your " + account_type + " was " + withdrawal_status+"."
    print(withdrawal_statement)
    return savings_balance, checking_balance

### Test of the make_withdrawal function

savings_balance, checking_balance = make_withdrawal("savings", 11, checking_balance, savings_balance)

check_balance("savings",checking_balance, savings_balance)



savings_balance, checking_balance = make_withdrawal("checking", 170, checking_balance, savings_balance)

check_balance("checking", checking_balance, savings_balance)


### Definition of the acc_transfer function

def acc_transfer(acc_from, acc_to, amount, checking_balance, savings_balance):
    transaction_status = str()
    trans_error = "unsuccessful, please enter amount less than "
    if acc_from == "savings" : 
        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" :
        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 your " + acc_to + " account was " + transaction_status +"."
    print(transaction_statement)
    return savings_balance, checking_balance

### Test of the acc_transfer function

savings_balance, checking_balance = acc_transfer("checking", "savings", 40, checking_balance, savings_balance)

print(check_balance("checking", checking_balance, savings_balance))

print(check_balance("savings", checking_balance, savings_balance))



savings_balance, checking_balance = acc_transfer("savings", "checking", 5, checking_balance, savings_balance)

print(check_balance("checking", checking_balance, savings_balance))

print(check_balance("savings", checking_balance, savings_balance))

Print("Thanks so much if you are here")