DEV Community

Hala Kabir
Hala Kabir

Posted on

I Built a Fun Functional ATM in Python (And It Taught Me More Than I Expected 💳🐍)

Ever wondered how an ATM actually thinks?

No fancy screens.
No touch panels.
Just pure logic deciding whether you can withdraw cash… or get politely rejected 😅

So I decided to build a fun, functional ATM system in Python—and along the way, I learned how real-world software is structured, secured, and tested.

Let’s break it down 👇

🏧 What Our Python ATM Can Do

This mini ATM system supports:

✅ PIN authentication
✅ Balance checking
✅ Cash withdrawal
✅ Deposit money
✅ Clean menu-driven flow
✅ Error handling (no negative withdrawals 😉)

All in pure Python, no external libraries.
**
🎭 Think of an ATM Like a Gatekeeper**

An ATM doesn’t care who you are.
It only cares about rules.

Correct PIN?
Enough balance?
Valid amount?

That’s exactly how our Python ATM will behave.

🧠 Step 1: The Brain (Account Data)
account = {
"pin": "1234",
"balance": 5000
}

Simple. Clear. Effective.

🔐 Step 2: PIN Authentication (The Bouncer)
def authenticate():
pin = input("Enter your PIN: ")
if pin == account["pin"]:
print("✅ Access Granted\n")
return True
else:
print("❌ Incorrect PIN")
return False

No correct PIN = no party.

💰 Step 3: Check Balance
def check_balance():
print(f"💳 Your current balance is: Rs {account['balance']}")

Short and sweet.

💸 Step 4: Withdraw Money (With Rules!)
def withdraw():
amount = int(input("Enter amount to withdraw: "))

if amount <= 0:
    print("⚠️ Invalid amount")
elif amount > account["balance"]:
    print("❌ Insufficient balance")
else:
    account["balance"] -= amount
    print(f"✅ Withdrawal successful! New balance: Rs {account['balance']}")
Enter fullscreen mode Exit fullscreen mode

No overdrafts. No drama.

💵 Step 5: Deposit Money
def deposit():
amount = int(input("Enter amount to deposit: "))

if amount <= 0:
    print("⚠️ Invalid amount")
else:
    account["balance"] += amount
    print(f"✅ Deposit successful! New balance: Rs {account['balance']}")
Enter fullscreen mode Exit fullscreen mode

Best feature—money goes in 😄

🧭 Step 6: The ATM Menu (Where the Magic Happens)
def atm_menu():
while True:
print("\n🏧 ATM MENU")
print("1. Check Balance")
print("2. Withdraw Money")
print("3. Deposit Money")
print("4. Exit")

    choice = input("Choose an option: ")

    if choice == "1":
        check_balance()
    elif choice == "2":
        withdraw()
    elif choice == "3":
        deposit()
    elif choice == "4":
        print("👋 Thank you for using the ATM")
        break
    else:
        print("⚠️ Invalid choice")
Enter fullscreen mode Exit fullscreen mode

This loop keeps the ATM alive until the user walks away.

🚀 Step 7: Run the ATM
if authenticate():
atm_menu()

That’s it.
A working ATM—built from logic, not magic.

🎯 What This Tiny ATM Teaches You

This simple project covers real software concepts:

🔹 Functions & modular design
🔹 Input validation
🔹 State management
🔹 Security basics
🔹 User experience logic

These are the same principles used in:

Banking apps

Payment systems

Backend services

🧪 Want to Level It Up?

Try adding:

🔥 Multiple users
🔥 PIN retry limit
🔥 Transaction history
🔥 File-based storage
🔥 GUI or web interface

Each upgrade moves you closer to real-world app development.

🧠 Final Thought

Building small, fun projects like this ATM isn’t “toy coding.”
It’s how real developers learn to think.

If you can build an ATM,
you can build anything.

Happy coding 🐍💻

Top comments (3)

Collapse
 
embernoglow profile image
EmberNoGlow

Good. By the way, starting with Python 3.10+, you can make if-elif-else statements more compact, beautiful, and elegant using match and case:


match choice:
        case "1":
            check_balance()
        case "2":
            withdraw()
        case "3":
            deposit()
        case "4":
            print("👋 Thank you for using the ATM")
            break
        case _:
            print("⚠️ Invalid choice")
Enter fullscreen mode Exit fullscreen mode

You can also add the word 'Python' before the three backticks to highlight the code. This is a handy Markdown feature.

Collapse
 
halakabir234hub profile image
Hala Kabir

Great tip—thank you for sharing this! 🙌
match / case definitely makes menu-driven logic cleaner and more readable in Python 3.10+, and it fits this ATM example really well. Also appreciate the Markdown tip about adding python after the backticks for proper syntax highlighting—small detail, big improvement. I’ll keep both in mind for future updates 👍

Collapse
 
halakabir234hub profile image
Hala Kabir

Best learning guide by Hala Kabir a young app and chatbot developer.....