<jupyter_start><jupyter_text>Bank Teller Solution In this project you will be implementing code that emulates transactions performed between a bank-teller and a customer. The prerequisites for this project are Python 3 syntax, functions and control flow. Let's jump right into it!  1. Initializing savings and checking account values. Creates two variables, one named `checking_balance` and the other `savings_balance`. Assign them both the value of zero. Use these as your starting bank balances.<jupyter_code>#initial checking_account_balance
checking_balance = 0

#initial saving_account_balance
savings_balance = 0<jupyter_output><empty_output><jupyter_text>2. Create a function to check the Balance step 1. Check account_type and return the respective balance    Define a function named `check_balance()` that accepts three parameters `account_type`, `checking_balance` and `savings_balance`. `account_type` represents a string which can either be `"savings"` or `"checking"`. `checking_balance` and `savings_balance`represent the respective number balances.     step 2. Check account_type and return the respective balance    Within the function named `check_balance()`, create an if...elif...else statement. Within each if statement return the customers balance based on the type of `account_type` they requested.    step 3. Assigning the savings_balance   Within the first `if` statement use an equal operator to check whether `account_type` is the same as `"savings"`. If that is true, set the new variable `balance` to the value of `savings_balance`.    step 4. Assigning the checking_balance   Within the second `elif` statement use an equal operator to check whether `account_type` is the same as `"checking"`. If that is true, set the variable `balance` to the value of `checking_balance`.    step 5. Return an error statement if there are no matching account_type   Within the `else` statement, return an error statement given that there were no matches for the previous `if...elif` statements. Within the else statement, `return` `"Unsuccessful, please enter \"checking\" or \"savings\""`    step 6. Create a balance statement   Under the `if` statements, create a new variable called `balance_statement` and assign it a value that consists of strings and variables. Concatenate the variables `account_type` and `balance` into the account statement. Remember to cast `balance` to a string using `str()` in the statement. The statement should be: "Your `account_type` balance is `balance`".    step 7. Return balance statement   Under the `balance_statement` assignment, close out the `check_balance()` function by adding a `return` statement that returns the `balance_statement` variable.<jupyter_code>#check_balance definition
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) + ".\n"
    return balance_statement<jupyter_output><empty_output><jupyter_text>3. Calling and Printing the check_balance() function for Checking Account Now that you have completed the `check_balance()` function, call it inside a `print()` function. Call the `check_balance()` function with these arguments; `"checking"`, `checking_balance` and `savings_balance`. The latter two were already initialized at the start of the project. Your checking balance should print.<jupyter_code>#check checking balance call
print(check_balance("checking",checking_balance,savings_balance))<jupyter_output>Your checking balance is 0.<jupyter_text>4. Calling and Printing the check_balance() function for Savings Account On the next line, inside a `print()` function call the `check_balance()` function with these arguments; `"savings"`, `checking_balance` and `savings_balance`. Your savings balance should print.<jupyter_code>#check savings balance call
print(check_balance("savings",checking_balance,savings_balance))<jupyter_output>Your savings balance is 0.<jupyter_text>5. Create a function to make a deposit step 1. define functionDefine 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.    step 2. Initialize deposit_status variableInside the deposit function, start by creating a variable named `deposit_status` and assign it to a an empty string    step 3. Ensure deposit is greater than 0 Write an if statement that checks whether the passed in `amount` is greater than 0. Step 5 will continue putting code inside this `if` statement if `amount` is greater than 0. step 4. Error if amount is less than 0Write a corresponding `else` statement if the `if` statement fails. Within that `else`, assign the variable `deposit_status` to the string value `"unsuccessful, please enter an amount greater than 0"`   step 5. Checking account_typeWithin the `if` statement that ensures that the amount is greater than 0, write inner `if...elif...else` statements. Within each if statement add the passed in `amount` to the customers balance based on the type of `account_type` they requested and also set `deposit_status` to `"successful"` or an error message.    step 6. Deposit to Savings accountWithin the first nested `if` statement check whether `account_type` is equivalent to `"savings"`. Then within this `if` statement on the next line add `amount` to `savings_balance` using the `+=` assignment operator. On the next line assign the string value `"successful"` to the variable `deposit_status`.   step 7. Deposit to Checking accountWithin the next nested `elif` statement check whether `account_type` is equivalent to `"checking"`. Then within this `elif` statement on the next line add `amount` to `checking_balance` using the `+=` assignment operator. On the next line assign the string value `"successful"` to the variable `deposit_status`.   step 8. Assign an error statement if there are no matching account_typeWithin the next nested `else` statement, assign the string value `"Unsuccessful, please enter \"checking\" or \"savings\""` to the variable `deposit_status`.   step 9. Create a deposit statementOutside of all the `if` statements but still in the function, compose a statement composing of strings and variables used in this function. Then assign it to the new `deposit_statement` variable. The statement should be: "Deposit of `amount` to your `account_type` account was `deposit_status`".  step 10. Print deposit statementOn the next line, write a print statement with the `deposit_statement` as an argument. This will print the deposit statement anytime the deposit function is called.  step 11. Return savings_balance and checking_balanceOn the next line return both the `savings_balance` and `checking_balance`. This will conclude the `make_deposit()` function.<jupyter_code>#deposit function
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) + " dollars to your " + account_type + " account was " + deposit_status + "."

    #print deposit statement
    print(deposit_statement)
    
    return savings_balance, checking_balance<jupyter_output><empty_output><jupyter_text>6. Call deposit function and make a savings depositOn the next line, call the `make_deposit()` function with these arguments; `"savings"`, `10`,`checking_balance` and `savings_balance`. Assign the function call to the matching `checking_balance` and `savings_balance` variables that are also being returned by the function. That is how the new balances are being updated.<jupyter_code>#update bank account after savings deposit
savings_balance, checking_balance = make_deposit("savings",10,checking_balance,savings_balance)<jupyter_output>Deposit of 10 dollars to your savings account was successful.<jupyter_text>7. Print savings balance call after making a savings depositNow that a deposit has been made to the savings account, print your savings balance. Call the `check_balance()` function with these arguments; `"savings"`, `checking_balance` and `savings_balance` within a print function. Your new savings balance should print.<jupyter_code>#check savings balance call after deposit
print(check_balance("savings",checking_balance,savings_balance))<jupyter_output>Your savings balance is 10.<jupyter_text>8. Call deposit function and make a checking depositOn the next line, call the `make_deposit()` function with these arguments; `"checking"`, `200`,`checking_balance` and `savings_balance`. Assign the function call to the matching `checking_balance` and `savings_balance` variables that are also being returned by the function.<jupyter_code>#update bank account after checking deposit
savings_balance, checking_balance = make_deposit("checking",200,checking_balance,savings_balance)<jupyter_output>Deposit of 200 dollars to your checking account was successful.<jupyter_text>9. Print checking balance call after making a checking depositNow that a deposit has been made to the checking account, print our new checking balance. Call the `check_balance()` function with these arguments; `"checking"`, `checking_balance` and `savings_balance` within a print function. Your new checking balance should print.<jupyter_code>#check checking balance call after deposit
print(check_balance("checking",checking_balance,savings_balance))<jupyter_output>Your checking balance is 200.<jupyter_text>10. Create a function to make a withdrawal step 1. define functionDefine a function named `make_withdrawal()` that accepts four parameters `account_type`, `amount`, `checking_balance` and `savings_balance`. The `amount` represents the withdrawal amount.  step 2. Initialize withdrawal_status variableInside the withdrawal function, start by creating a variable named `withdrawal_status` and assign it to an empty string.  step 3. Initialize an error messageOn the next line create a variable named `fail` and assign it to the value `"unsuccessful, please enter amount less than balance"`  step 4. Checking account_typeWrite `if...elif...else` statements. Within each if statement check whether the `account_type` is equivalent to `savings_balance` or `checking_balance`. If neither, throw an error in the else statement. step 5. Withdrawal from savings accountThe first `if` statement should check whether `account_type` is equivalent to `"savings"`.  step 6. Ensure withdrawal is less than savings accountThen write an inner `if...else` that checks if the withdrawal amount is greater than the savings balance. If the amount is indeed greater, in the else statement, assign `withdrawal_status` to the variable `fail`. step 7. Subtract amount from savings accountWithin the inner `if` statement, subtract `amount` from the `savings_balance` using the `-=` assignment operator. On the next line assign the string value `"successful"` to the variable `withdrawal_status`.  step 8. Withdrawal from checking accountThe next `elif` statement should check whether `account_type` is equivalent to `"checking"`.  step 9. Ensure withdrawal is less than checking accountThen write an inner `if...else` that checks if the withdrawal amount is greater than the checking balance. If the amount is indeed greater, in the else statement, assign `withdrawal_status` to the variable `fail`. step 10. Subtract amount from checking accountWithin the inner `if` statement, subtract `amount` from the `checking_balance` using the `-=` assignment operator. On the next line assign the string value `"successful"` to the variable `withdrawal_status`.  step 11. Assign an error statement if there are no matching account_typeWithin the last `else` statement, assign the string value `"unsuccessful, please enter \"checking\" or \"savings\""` to the variable `withdrawal_status`. step 12. Create a withdrawal statementOutside of all the `if` statements but still in the function, create a statement composing of strings and variables used in this function. Then assign it to the new `withdrawal_statement` variable. The withdrawal statement should be: "Withdrawal of `amount` from your `account_type` was `withdrawal_status`".  step 13. Print withdrawal statementOn the next line, write a print statement with the `withdrawal_statement` as an argument. This will print the withdrawal statement anytime the deposit function is called.  step 14. Return savings_balance and checking_balanceOn the next line return both the `savings_balance` and `checking_balance`. This will conclude the `make_withdrawal()` function.<jupyter_code>#withdrawal function
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 = "successful"
        else:
            withdrawal_status = fail
    elif account_type == "checking":
        if amount <= checking_balance:
            checking_balance -= amount
            withdrawal_status = "successful"
        else:
            withdrawal_status = fail
    else:
        withdrawal_status = acc_error
    
    withdrawal_statement = "Withdrawal of "+ str(amount) + " from your " + account_type + " account was " + withdrawal_status + "."

    #print withdrawal statement
    print(withdrawal_statement)
    
    return savings_balance, checking_balance<jupyter_output><empty_output><jupyter_text>11. Call withdrawal function and make a savings withdrawalOn the next line, call the `make_withdrawal()` function with these arguments: `"savings"`, `11`,`checking_balance` and `savings_balance`. Assign the function call to the matching `checking_balance` and `savings_balance` variables that are also being returned by the function. That is how the new balances are being updated.<jupyter_code>#update bank account after savings withdrawal
savings_balance, checking_balance = make_withdrawal("savings",11,checking_balance,savings_balance)<jupyter_output>Withdrawal of 11 from your savings account was unsuccessful, please enter amount less than balance.<jupyter_text>12. Print savings balance call, after making a savings withdrawalNow that a withdrawal has been made from the savings account, print our savings balance. Call the `check_balance()` function with these arguments; `"savings"`, `checking_balance` and `savings_balance` within a print function. Your new savings balance should print.<jupyter_code>#check savings balance call after deposit
print(check_balance("savings",checking_balance,savings_balance))<jupyter_output>Your savings balance is 10.<jupyter_text>13. Call withdrawal function and make a checking withdrawalOn the next line, call the `make_withdrawal()` function with these arguments; `"checking"`, `170`,`checking_balance` and `savings_balance`. Assign the function call to the matching `checking_balance` and `savings_balance` variables that are also being returned by the function. That is how the new balances are being updated.<jupyter_code>#update bank account after checking withdrawal
savings_balance, checking_balance = make_withdrawal("checking",170,checking_balance,savings_balance)<jupyter_output>Withdrawal of 170 from your checking account was successful.<jupyter_text>14. Print checking balance call, after making a checking withdrawalNow that a withdrawal has been made from the checking account, print our checking balance. Call the `check_balance()` function with these arguments; `"checking"`, `checking_balance` and `savings_balance` within a print function. Your new checking balance should print.<jupyter_code>#check savings balance call after deposit
print(check_balance("checking",checking_balance,savings_balance))<jupyter_output>Your checking balance is 30.<jupyter_text>15. Create a function to make a transfer between accounts step 1. define functionDefine a function named `acc_transfer()` that accepts five parameters `acc_from`, `acc_to`, `amount`, `checking_balance` and `savings_balance`. step 2. Initialize transaction_status variableInside the transfer function, start by creating a variable named `transaction_status` and assign it to a an empty string.  step 3. Initialize an error messageOn the next line create a variable named `trans_error` and assign it to the value `"unsuccessful, please enter amount less than "`  step 4. Account TransferWrite `if...elif...else` statements. The `if` statement will check if the transfer is from savings to checking account. The `elif` statement will check if the transfer is from checking to savings account. If neither, throw an error in the else statement. step 5. Ensure transfer is less than savings accountWithin the first `if` statement, write an inner `if...else` that checks if the transfer amount is greater than the savings balance. If the amount is indeed greater, in the else statement, assign `transaction_status` to the variable `trans_error` + `str(savings_balance)`. step 6. Transfer amount from savings to checking accountWithin the inner `if` statement, subtract `amount` from the `savings_balance` using the `-=` assignment operator. On the next line, add `amount` to the `checking_balance` using the `+=` assignment operator. Then on the next line assign the string value `"successful"` to the variable `transaction_status`.  step 7. Ensure transfer is less than checking accountWithin the following `elif` statement, write an inner `if...else` that checks if the transfer amount is greater than the checking balance. If the amount is indeed greater, in the else statement, assign `transaction_status` to the variable `trans_error` + `str(checking_balance)`. step 8. Transfer amount from checking to savings  accountWithin the inner `if` statement, subtract `amount` from the `checking_balance` using the `-=` assignment operator. On the next line, add `amount` to the `savings_balance` using the `+=` assignment operator. Then on the next line assign the string value `"successful"` to the variable `transaction_status`.  step 9. Assign an error statement if there are no matching account_typeWithin the last `else` statement, assign the string value `"unsuccessful, please enter \"checking\" or \"savings\""` to the variable `transaction_status`. step 10. Create a transfer statementOutside of all the `if` statements but still in the function, compose a statement composing of strings and variables used in this function. Then assign it to the new `transaction_statement` variable. The transfer statement should be; "Transfer of `amount` from your `cc_from` to your `acc_to` account was `transaction_status`". step 11. Print transfer statementOn the next line, write a print statement with the `transaction_statement` as an argument. This will print the transfer statement anytime the transfer function is called.  step 12. Return savings_balance and checking_balanceOn the next line return both the `savings_balance` and `checking_balance`. This will conclude the `acc_transfer()` function.<jupyter_code>#account transfer
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:
            savings_balance -= amount
            checking_balance += amount
            transaction_status = "successful"
        else:
            transaction_status = trans_error + str(savings_balance)
    elif acc_from == "checking" and acc_to == "savings":
        if amount <= checking_balance:
            checking_balance -= amount
            savings_balance += amount
            transaction_status = "successful"
        else:
            transaction_status = trans_error + str(checking_balance)
    else:
        transaction_status = acc_error
    
    transaction_statement = "Transfer of "+ str(amount) + " from your " + acc_from + " to your "+ acc_to +" account was " + transaction_status + "."

    #print transfer statement
    print(transaction_statement)

    return savings_balance, checking_balance<jupyter_output><empty_output><jupyter_text>16. Call transfer function and make a checking to savings transferOn the next line, call the `acc_transfer()` function with these arguments; `"checking"`, `"savings"`, `30`,`checking_balance` and `savings_balance`. Assign the function call to the matching `checking_balance` and `savings_balance` variables that are also being returned by the function.<jupyter_code>#update bank account after transfer checking to savings
savings_balance, checking_balance = acc_transfer("checking","savings",40,checking_balance,savings_balance)<jupyter_output>Transfer of 40 from your checking to your savings account was unsuccessful, please enter amount less than 30.<jupyter_text>17. Print checking balance after making a checking to savings transferNow that a transfer has been made from the checking to savings account, print your checking balance. Call the `check_balance()` function with these arguments; `"checking"`, `checking_balance` and `savings_balance` within a print function. Your new checking balance should print.<jupyter_code>#check checking balance call after transfer
print(check_balance("checking",checking_balance,savings_balance))<jupyter_output>Your checking balance is 30.<jupyter_text>18. Print savings balance after making a checking to savings transferNow that a transfer has been made from the checking to savings account, print your savings balance. Call the `check_balance()` function with these arguments; `"savings"`, `checking_balance` and `savings_balance` within a print function. Your new savings balance should print.<jupyter_code>#check savings balance call after deposit
print(check_balance("savings",checking_balance,savings_balance))<jupyter_output>Your savings balance is 10.<jupyter_text>19. Call transfer function and make a savings to checking transferOn the next line, call the `acc_transfer()` function with these arguments; `"savings"`, `"checking"`, `5`,`checking_balance` and `savings_balance`. Assign the function call to the matching `checking_balance` and `savings_balance` variables that are also being returned by the function. That is how the new balances are being updated.<jupyter_code>#update bank account after transfer savings to checking
savings_balance, checking_balance = acc_transfer("savings","checking",5,checking_balance,savings_balance)<jupyter_output>Transfer of 5 from your savings to your checking account was successful.<jupyter_text>20. Print checking balance after making a savings to checking transferNow that a transfer has been made from the savings to checking account, print your checking balance. Call the `check_balance()` function with these arguments; `"checking"`, `checking_balance` and `savings_balance` within a print function. Your new checking balance should print.<jupyter_code>#check savings balance call after transfer
print(check_balance("checking",checking_balance,savings_balance))<jupyter_output>Your checking balance is 35.<jupyter_text>21. Print saving balance after making a savings to checking transferNow that a transfer has been made from the savings to checking account, print your saving balance. Call the `check_balance()` function with these arguments; `"savings"`, `checking_balance` and `savings_balance` within a print function. Your new saving balance should print.<jupyter_code>#check savings balance call after deposit
print(check_balance("savings",checking_balance,savings_balance))<jupyter_output>Your savings balance is 5.
{'fraction_non_alphanumeric': 0.07014708928941371, 'fraction_numerical': 0.00654650921897659, 'mean_word_length': 5.39364238410596, 'pattern_counts': {'":': 8, '<': 73, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '21', 'dir': 'jupyter-structured-clean-dedup', 'id': '76242', 'license': 'MIT', 'n_tokens_mistral': 6265, 'n_tokens_neox': 5885, 'n_words': 2789, 'path': 'bank_teller.ipynb', 'repo_name': 'raduceaca1234/Analyze-Financial-Data-with-Python', 'size': '24135'}