Day 2 of Problem Solving Series In Python

Day 2 of Problem Solving Series In Python | Geethu Talks

Day 2 of Problem Solving Series

Day 2 of Problem Solving Series

👋 Hi friends! Geethu Talks ki welcome. UPI payment chesaka balance ela calculate avuthundo ee roju Python tho chuddam.

🎬 Reel chudaledha? Instagram / YouTube lo @GeethuTalks ni follow avvandi.

🧩 Real-life Problem

Mee account lo ₹2,000 unnayi. Online lo headphones ₹799 ki konnaru. Payment tarvatha entha money migulutundi?

📋 Task: Balance and purchase amount teesukuni remaining balance print cheyyandi. Purchase ekkuva ayithe ‘Insufficient balance’ cheppandi.
📥 Sample input: Balance = ₹2000, Purchase = ₹799
📤 Sample output: Remaining balance: ₹1201.00

📚 Concepts Covered

  • ➕ Arithmetic operators: + - * /
  • 📦 Variables lo values store cheyadam
  • 🔢 float() tho decimal numbers
  • 🔀 if-else tho balance check

🧠 Step 1: Logic Build Cheddam

Yesterday division use chesam. Today subtraction! Steps:

  1. Account balance teesukovali
  2. Purchase amount teesukovali
  3. Purchase balance kanna ekkuva ayithe payment fail
  4. Lekapothe balance nunchi purchase subtract cheyyali
₹2000 − ₹799 = ₹1201

💡 Analogy: Arithmetic operators calculator buttons laga: + add, - subtract, * multiply, / divide.

💻 Step 2: Python Code

balance = float(input("Balance: "))
purchase = float(input("Purchase amount: "))

if purchase <= balance:
    remaining = balance - purchase
    print(f"Remaining balance: ₹{remaining:.2f}")
else:
    print("Insufficient balance")

✅ Output
Balance: 2000
Purchase amount: 799
Remaining balance: ₹1201.00

🔍 Line by line


CodeMeaning
balance = float(...)Balance ni number ga store cheyadam
purchase = float(...)Purchase amount ni number ga store cheyadam
if purchase <= balanceMoney sufficient ga undha ani check
balance - purchaseSubtraction tho remaining amount
elseBalance takkuva ayithe error message

⚠️ Common Mistake Alert

❌ Wrong: Input ni number ga marchakunda subtract cheyyadam

balance = input("Balance: ")
purchase = input("Purchase amount: ")
remaining = balance - purchase
# TypeError: unsupported operand type(s) for -: 'str' and 'str'

✅ Right: float(input(...)) use chesi number ga marchandi.

💡 Bonus tip: "2000" (text) ki 2000 (number) ki difference undi. Text tho minus cheyyalem!

📝 Quick Recap

  • ✔️ Subtraction tho remaining money kanukkunnam
  • ✔️ float() tho input ni number ga marchamu
  • ✔️ if-else tho insufficient balance case handle chesam

🏋️ Practice Problems

🟢 Easy: Balance ₹1500, shopping ₹650. Remaining entha?
Expected output: ₹850.00


🟡 Medium: Moodu items prices (₹120, ₹250, ₹99) teesukuni total price print cheyyandi.
Expected output: Total: ₹469.00


🔴 Challenge: Balance ₹3000. Rendu items konnaru: ₹799 and ₹1250. Remaining entha? Money saripoka pothe ‘Insufficient balance’ cheppandi.
Expected output: ₹951.00


💬 Mee answers comments lo share cheyyandi!

🚀 Next: Day 3 – Exam Pass or Fail

Follow @GeethuTalks and stay tuned! 💛

⬅️ Previous: Day 1 of Problem Solving Series In Python

check out our website for more resources

1 thought on “Day 2 of Problem Solving Series In Python”

Leave a Comment