The file contains lines of codes to build an Automated Teller Machine (ATM) simulator.
account = { 'name': 'Eugenia Ishaku', 'balance': 5000, 'pin': 1234 }
def display_menu(): print(f"\nWelcome to the ATM {account['name']}.") print("1. Check Balance") print("2. Deposit Cash") print("3. Withdaw Cash") print("4. Exit") choice = input("Please select an option (1-4): ") return choice
def check_balance(): print(f"Your current balance is: N{account['balance']}")
def deposit_cash(): amount = float(input("Enter the amount to deposit: ")) if amount > 0: account['balance'] += amount print(f"N{amount} has been deposited. Your new balnce is: N{account['balance']}") else: print("Invalid amount. Please enter a valid amount.")
def withdraw_cash(): amount = float(input("Enter the amount to withdraw: ")) if amount > 0: if amount < account['balance']: account['balance'] -= amount print(f"N{amount} has been withdrawn. Your new balance is: N{account['balance']}") else: print("Insufficient funds.") else: print("Invalid amount. Please enter a valid amount.")
def atm_sim(): pin = int(input("Please enter your PIN: ")) if pin == account['pin']: while True: choice = display_menu() if choice == '1': check_balance() elif choice == '2': deposit_cash() elif choice == '3': withdraw_cash() elif choice == '4': print("Thank you for using this ATM.") print("Take your card") break else: print("Invalid choice. Please select a valid option (1-4).") another = input("\nDo you want to perform another transaction? (yes/no): ").lower() if another != 'yes': print("Thank you for using this ATM") print("Take your card") break
else:
print("Incorrect PIN. Please try again.")