DAY 49 — 60 DAY PYTHON CHALLENGE
ATM Simulator
Python mein ATM Simulator banao — Hindi mein step by step
Advertisement
Project kya hai?
Day 49 ka project hai ATM Simulator!
Yeh project banane se aap Python ke important concepts
practice kar payenge. Neeche complete code hai — copy karo aur chalao!
Complete Python Code
python — atm.py
class ATM:
def __init__(self, name, balance, pin):
self.name = name
self.balance = balance
self.pin = str(pin)
self.attempts = 0
self.locked = False
def verify(self, pin):
if self.locked:
print("Card lock ho gaya hai! Bank se contact karo.")
return False
if pin == self.pin:
self.attempts = 0
return True
self.attempts += 1
remaining = 3 - self.attempts
if remaining == 0:
self.locked = True
print("3 baar galat PIN! Card lock ho gaya!")
else:
print(f"Galat PIN! {remaining} try bachi hain.")
return False
def withdraw(self, amt):
if amt <= 0 or amt % 100 != 0:
print("100 ke multiple mein amount dalo!")
return
if amt > self.balance:
print("Balance kam hai!")
return
self.balance -= amt
print(f"Rs{amt:,} nikale gaye!")
print(f"Bacha balance: Rs{self.balance:,}")
def deposit(self, amt):
if amt <= 0:
print("Amount sahi nahi!")
return
self.balance += amt
print(f"Rs{amt:,} jama ho gaye!")
print(f"Total balance: Rs{self.balance:,}")
atm = ATM("Rahul Kumar", 25000, 1234)
print("=== Python ATM ===")
pin = input("PIN enter karo: ")
if not atm.verify(pin):
print("Access denied!")
else:
print(f"\nNamaste, {atm.name}!")
while True:
print(f"\nBalance: Rs{atm.balance:,}")
print("1. Withdraw")
print("2. Deposit")
print("3. Balance check")
print("4. Baahar jao")
ch = input("Choice: ")
if ch == "1": atm.withdraw(int(input("Amount (100 ka multiple): Rs")))
elif ch == "2": atm.deposit(int(input("Deposit amount: Rs")))
elif ch == "3": print(f"Balance: Rs{atm.balance:,}")
elif ch == "4": print("Shukriya!"); break
OUTPUT
=== Python ATM === PIN enter karo: 1234 Namaste, Rahul Kumar! Balance: Rs25,000 Amount: Rs5000 Rs5,000 nikale gaye! Bacha balance: Rs20,000
Code kaise kaam karta hai?
3 galat PIN se card lock ho jata hai - real ATM ki tarah! Amount 100 ka multiple hona chahiye. OOP se real ATM behavior implement hota hai.
Advertisement
📋 Project ka Introduction
ATM Simulator Python ka Day 49 ka project hai. Is project mein aap Python ke important concepts practice karenge jo real-world applications mein bahut use hote hain.
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
🧠 Is Project mein kya seekhoge?
Yeh project banate waqt aap ye Python concepts use karoge:
| Concept | Kya karta hai |
|---|---|
Variables | Data store karna |
Functions | Reusable code blocks |
Loops | Repeat karna |
Conditions | Decisions lena |
Input/Output | User se interact karna |
📝 Code kaise kaam karta hai — Step by Step
Neeche code ki poori logic step-by-step samjhayi gayi hai:
- Problem samjho: ATM Simulator mein kya karna hai
- Required variables aur data structures decide karo
- Logic step-by-step likhó
- Code mein implement karo
- Test karo aur bugs fix karo
⚠️ Common Mistakes — Bhool mat jaana!
Beginners yeh galtiyan aksar karte hain — dhyan rakho:
- ⚠️ Indentation sahi rakho — Python mein spaces matter karti hain
- ⚠️ Variables ko use se pehle define karo
- ⚠️ Input ko int()/float() mein convert karo agar number chahiye
- ⚠️ Edge cases handle karo — kya hoga agar user galat input de?
🏋️ Practice Exercises — Aage badho!
Yeh project complete karne ke baad in exercises se practice karo:
- 💡 ATM Simulator mein naya feature add karo
- 💡 Code ko functions mein refactor karo
- 💡 Error handling improve karo
- 💡 File mein data save karo
❓ Aksar Pooche Jane Wale Sawal (FAQ)
Q: ATM Simulator project kyon banana chahiye?
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
Q: Code run nahi ho raha?
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
Q: Kaise improve karein?
A: Pehle basic version complete karo, phir ek ek feature add karte jao.
A: Pehle basic version complete karo, phir ek ek feature add karte jao.