Bank Teller Project
import zipfile
import os
Specify the path to your zip file
zip_file_path = r"C:\Users\adm\Downloads\bank_teller.zip"
Specify the directory where you want to extract the contents
extracted_dir = r"C:\Users\adm\Downloads\bank_teller_extracted"
Create the directory if it doesn’t exist
os.makedirs(extracted_dir, exist_ok=True)
Extract the contents of the zip file
with zipfile.ZipFile(zip_file_path, ‘r’) as zip_ref:
zip_ref.extractall(extracted_dir)
List the files in the extracted directory
extracted_files = os.listdir(extracted_dir)
print(“Extracted Files:”, extracted_files)
Extracted Files: [‘bank_teller’, ‘__MACOSX’]
class BankAccount:
def init(self):
self.checking_balance = 0.0
self.savings_balance = 0.0
def get_balance(self, account_type):
if account_type.lower() == “checking”:
return self.checking_balance
elif account_type.lower() == “savings”:
return self.savings_balance
else:
return “Invalid account type”
def deposit(self, account_type, amount):
if account_type.lower() == “checking”:
self.checking_balance += amount
return f"Deposited ${amount} into checking account. New balance: ${self.checking_balance}"
elif account_type.lower() == “savings”:
self.savings_balance += amount
return f"Deposited ${amount} into savings account. New balance: ${self.savings_balance}"
else:
return “Invalid account type”
def withdraw(self, account_type, amount):
if account_type.lower() == “checking” and amount <= self.checking_balance:
self.checking_balance -= amount
return f"Withdrew ${amount} from checking account. New balance: ${self.checking_balance}"
elif account_type.lower() == “savings” and amount <= self.savings_balance:
self.savings_balance -= amount
return f"Withdrew ${amount} from savings account. New balance: ${self.savings_balance}"
else:
return “Insufficient funds or invalid account type”
def transfer(self, source_account, destination_account, amount):
if source_account.lower() == “checking” and destination_account.lower() == “savings” and amount <= self.checking_balance:
self.checking_balance -= amount
self.savings_balance += amount
return f"Transferred ${amount} from checking to savings. Checking balance: ${self.checking_balance}, Savings balance: ${self.savings_balance}"
elif source_account.lower() == “savings” and destination_account.lower() == “checking” and amount <= self.savings_balance:
self.savings_balance -= amount
self.checking_balance += amount
return f"Transferred ${amount} from savings to checking. Checking balance: ${self.checking_balance}, Savings balance: ${self.savings_balance}"
else:
return “Insufficient funds or invalid account type”
Creating a bank account
my_account = BankAccount()
Testing the functions
print(“Checking Balance:”, my_account.get_balance(“checking”))
print(“Savings Balance:”, my_account.get_balance(“savings”))
Create a bank account
my_account = BankAccount()
Display initial balances
print(“Initial Checking Balance:”, my_account.get_balance(“checking”))
print(“Initial Savings Balance:”, my_account.get_balance(“savings”))
Deposit money
print(my_account.deposit(“checking”, 100.0))
print(my_account.deposit(“savings”, 50.0))
Withdraw money
print(my_account.withdraw(“checking”, 30.0))
print(my_account.withdraw(“savings”, 20.0))
Transfer between accounts
print(my_account.transfer(“checking”, “savings”, 10.0))
print(my_account.transfer(“savings”, “checking”, 5.0))
Display final balances
print(“Final Checking Balance:”, my_account.get_balance(“checking”))
print(“Final Savings Balance:”, my_account.get_balance(“savings”))
Checking Balance: 0.0
Savings Balance: 0.0
1
checking_balance = 0.0
savings_balance = 100.0
Define functions for banking operations.
def display_balance(account_type):
if account_type == “checking”:
return checking_balance
elif account_type == “savings”:
return savings_balance
def make_deposit(account_type, amount):
global checking_balance, savings_balance
if account_type == “checking”:
checking_balance += amount
elif account_type == “savings”:
savings_balance += amount
def make_withdrawal(account_type, amount):
global checking_balance, savings_balance
if account_type == “checking”:
checking_balance -= amount
elif account_type == “savings”:
savings_balance -= amount
def make_transfer(from_account, to_account, amount):
global checking_balance, savings_balance
if from_account == “checking” and to_account == “savings”:
checking_balance -= amount
savings_balance += amount
elif from_account == “savings” and to_account == “checking”:
savings_balance -= amount
checking_balance += amount
Test the bank teller functions.
print(“Checking balance:”, display_balance(“checking”))
print(“Savings balance:”, display_balance(“savings”))
make_deposit(“checking”, 200.0)
make_withdrawal(“savings”, 100.0)
print(“Checking balance after deposit:”, display_balance(“checking”))
print(“Savings balance after withdrawal:”, display_balance(“savings”))
make_transfer(“checking”, “savings”, 50.0)
print(“Checking balance after transfer:”, display_balance(“checking”))
print(“Savings balance after transfer:”, display_balance(“savings”))
Checking balance: 0.0
Savings balance: 100.0
Checking balance after deposit: 200.0
Savings balance after withdrawal: 0.0
Checking balance after transfer: 150.0
Savings balance after transfer: 50.0