Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Enhanced Bank Account Management System
- # 🏦 Data Structures to Store Information
- account_holders = [] # Account names
- balances = [] # Account balances
- transaction_histories = [] # Account transaction logs
- loans = [] # Account loan details
- MAX_LOAN_AMOUNT = 10000
- INTEREST_RATE = 0.03
- def display_menu():
- """Main menu for banking system."""
- print("\n🌟 Welcome to Enhanced Bank System 🌟")
- print("1️⃣ Create Account")
- print("2️⃣ Deposit Money")
- print("3️⃣ Withdraw Money")
- print("4️⃣ Check Balance")
- print("5️⃣ List All Accounts")
- print("6️⃣ Transfer Funds")
- print("7️⃣ View Transaction History")
- print("8️⃣ Apply for Loan")
- print("9️⃣ Repay Loan")
- print("🔟 Identify Credit Card Type")
- print("0️⃣ Exit")
- def create_account():
- # TODO: Add logic
- """Create a new account."""
- counter = -1
- users_name = input("Please import your Username: ")
- account_holders.append(users_name)
- balances.append(0)
- loans.append(0)
- for i in balances:
- counter += 1
- print(f"This is your special number you need for further operations: {counter}")
- print(account_holders)
- print(loans)
- print(balances)
- def deposit():
- account_balance = 0
- """Deposit money into an account."""
- user_name = input("Please import your username: ")
- special_num = int(input("Please import your special number: "))
- if user_name in account_holders:
- amount = int(input("Please write amount of money: "))
- balances[special_num] += amount
- else:
- print("Incorrect username or special num!")
- print(f"Balance: {balances[special_num]}")
- def withdraw():
- """Withdraw money from an account."""
- # TODO: Add logic
- user_name = input("Please import your username: ")
- special_num = int(input("Please import your special number: "))
- if user_name in account_holders:
- amount = int(input("Please write amount of money: "))
- balances[special_num] -= amount
- else:
- print("Incorrect username or special num!")
- print(f"Balance: {balances[special_num]}")
- def check_balance():
- """Check balance of an account."""
- # TODO: Add logic
- username = input("To check your balance please import your username: ")
- special_num = int(input("Please import your special number: "))
- if username in account_holders:
- print(f"Balance: {balances[special_num]}")
- else:
- print("Incorrect username or special num!")
- def list_accounts():
- """List all account holders and details."""
- # TODO: Add logic
- print(f"Account holders: {account_holders}")
- print(f"Account balances: {balances}")
- print(f"Loans: {loans}")
- def transfer_funds():
- """Transfer funds between two accounts."""
- # TODO: Add logic
- senders_username = input("Please import your username: ")
- senders_special_num = int(input("Please import your special num: "))
- receivers_username = input("Please import receivers username: ")
- receivers_special_num = int(input("Please import receivers special num: "))
- amount = 0
- if senders_username in account_holders and receivers_username in account_holders:
- amount = int(input("Please import the amount you want to transfer: "))
- if amount > balances[senders_special_num]:
- print("Non-sufficient funds!")
- else:
- balances[senders_special_num] -= amount
- balances[receivers_special_num] += amount
- else:
- print("Incorrect username or special num!")
- operation = f"Sender: {senders_username} -> Receiver: {receivers_username} Amount: {amount}"
- transaction_histories.append(operation)
- print(balances)
- def view_transaction_history():
- """View transactions for an account."""
- # TODO: Add logic
- print(transaction_histories)
- def apply_for_loan():
- """Allow user to apply for a loan."""
- # TODO: Add logic
- username = input("Please import your username: ")
- special_num = int(input("Please import your special num: "))
- if username in account_holders:
- loan_amount = int(input("How much would you like to be loaned? Keep in mind that the maximum amount that we can provide is 10000: "))
- if loan_amount > MAX_LOAN_AMOUNT:
- print("Sorry, but your loan is not approved")
- else:
- years = int(input("In how many years would you like to pay it back: ")) # years of the loan
- print("Perfect the money is in your balance!")
- balances[special_num] += loan_amount
- interest = loan_amount * INTEREST_RATE * years
- loans[special_num] += interest + loan_amount
- else:
- print("Incorrect username or special num!")
- def repay_loan():
- """Allow user to repay a loan."""
- # TODO: Add logic
- username = input("Please import your username: ")
- special_num = int(input("Please import your special num: "))
- if username in account_holders:
- amount = int(input("How much would you like to pay: "))
- balances[special_num] -= amount
- loans[special_num] -= amount
- print(f"Your loan balance is: {loans[special_num]}")
- else:
- print("Incorrect username or special num!")
- def identify_card_type():
- """Identify type of credit card."""
- # TODO: Add logic
- card_number = int(input("Please import your card number: "))
- card_num_as_str = str(card_number)
- card_type = ""
- if len(card_num_as_str) == 16:
- for i in range(len(card_num_as_str)):
- if card_num_as_str[0] == "4":
- card_type = "Visa"
- elif card_num_as_str[0] == "2" or card_num_as_str[0] == "5":
- card_type = "Mastercard"
- elif card_num_as_str[0] == "3":
- card_type = "American Express"
- else:
- print("Invalid card number!")
- print(f"Card type: {card_type}")
- def main():
- """Run the banking system."""
- while True:
- display_menu()
- choice = int(input("Enter your choice: "))
- # Map choices to functions
- if choice == 1:
- create_account()
- elif choice == 2:
- deposit()
- elif choice == 3:
- withdraw()
- elif choice == 4:
- check_balance()
- elif choice == 5:
- list_accounts()
- elif choice == 6:
- transfer_funds()
- elif choice == 7:
- view_transaction_history()
- elif choice == 8:
- apply_for_loan()
- elif choice == 9:
- repay_loan()
- elif choice == 10:
- identify_card_type()
- elif choice == 0:
- print("Goodbye! 👋")
- break
- else:
- print("❌ Invalid choice. Try again!")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment