0–5 min
Real Hook
5–25 min
Core Concept
25–45 min
Live Coding
45–55 min
You Code It
55–60 min
Cheat Sheet
🔥 Real-World Hook (0–5 min)

Every Android app backend at Swiggy, every data pipeline at HDFC Bank, every automation script at TCS — Python.

Python is the #1 language for AI, data, and backend. Today you write a real ATM simulation with balance checks, deposits, and withdrawals — the same logic that runs on every bank's server.

☕ Python vs Every Other Language (5–25 min)

💡 Why Python is Different

No semicolons — indentation defines blocks (tabs = structure).
No types needed — x = 5 not int x = 5;
No main() — code at module level runs top-to-bottom.
No return type — def add(a, b) not public int add(int a, int b)

💻 Live Coding — ATM Simulation (25–45 min)

# atm.py

def create_account(owner, balance=0):
    # Python uses dict as a simple data holder
    return {"owner": owner, "balance": balance, "transactions": []}

def deposit(account, amount):
    if amount <= 0:
        print("Invalid amount")
        return
    account["balance"] += amount
    account["transactions"].append(("deposit", amount))
    print(f"Deposited ₹{amount}. Balance: ₹{account['balance']}")

def withdraw(account, amount):
    if amount > account["balance"]:
        print("Insufficient funds!")
    else:
        account["balance"] -= amount
        account["transactions"].append(("withdraw", amount))
        print(f"Withdrawn ₹{amount}. Remaining: ₹{account['balance']}")

def show_history(account):
    print(f"\n--- {account['owner']}'s History ---")
    for txn_type, amt in account["transactions"]:
        symbol = "+" if txn_type == "deposit" else "-"
        print(f"  {symbol}₹{amt}")


# Usage
acc = create_account("Priya", 10000)
deposit(acc, 5000)
withdraw(acc, 3000)
withdraw(acc, 20000)   # "Insufficient funds!"
show_history(acc)

🔄 Processing Transactions with a Loop

transactions = [500, -200, 1000, -50, -800]
balance = 5000

for t in transactions:
    if t > 0:
        balance += t
        print(f"  Deposit ₹{t}  → Balance: ₹{balance}")
    else:
        balance -= abs(t)
        print(f"  Withdraw ₹{abs(t)} → Balance: ₹{balance}")

print(f"Final: ₹{balance}")  # ₹4450
🎯 You Code It (45–55 min)
  1. Create a grade_calculator.py with function get_grade(marks)
  2. Logic: marks≥90="A", ≥75="B", ≥60="C", ≥50="D", else="F"
  3. Add function process_class(marks_list) — print grade for each student
  4. Add function class_average(marks_list) — return average (use sum() and len())
  5. Test: marks = [92, 45, 78, 63, 88, 31, 95]
  6. Show: All grades + class average printed

📄 Day 3 Cheat Sheet — Python Fundamentals

Variables & Types

name = "Priya"String
age = 21Integer
gpa = 3.9Float
active = TrueBoolean
type(x)Check type
str(42)int to string

Functions

def greet(name):Define
def add(a, b=0):Default param
return valueReturn
greet("Priya")Call
*argsVariable positional args
**kwargsVariable keyword args

Control Flow

if x > 0:Condition
elif x == 0:Else-if
else:Default
for x in items:For-each
for i in range(10):Count loop
while condition:While loop

Useful Built-ins

len(x)Length
sum(list)Sum all
max(list)Largest
min(list)Smallest
sorted(list)Sorted copy
enumerate(list)Index + value pairs