Day 4 of Problem Solving Series In Python

Day 4 of Problem Solving Series In Python | Geethu Talks

Day 4 of Problem Solving Series

Day 4 of Problem Solving Series

๐Ÿ‘‹ Hi friends! Geethu Talks ki welcome. 20% discount ante โ‚น20 thagguthaya? Kaadu! Ee roju percentage logic nerchukundam.

๐ŸŽฌ Reel chudaledha? Instagram / YouTube lo @GeethuTalks ni follow avvandi.

๐Ÿงฉ Real-life Problem

Food delivery app lo โ‚น500 or more bill ayithe 20% discount. Mee order โ‚น600. Final bill entha?

๐Ÿ“‹ Task: Cart amount teesukuni, bill โ‚น500 or more ayithe matrame 20% discount apply chesi final bill print cheyyandi.
๐Ÿ“ฅ Sample input: Bill = โ‚น600
๐Ÿ“ค Sample output: Final bill: โ‚น480.00

๐Ÿ“š Concepts Covered

  • ๐Ÿ“Š Percentage formula
  • ๐Ÿ”€ Conditional calculation
  • ๐Ÿ”ข float() input
  • ๐Ÿ–จ๏ธ f-string formatting

๐Ÿง  Step 1: Logic Build Cheddam

Mundu condition, tarvatha calculation:

  1. Bill 500 or above undha? Check cheyyali
  2. Yes ayithe: discount = bill ร— 20 รท 100
  3. Final bill = bill โˆ’ discount
  4. No ayithe: bill alage untundi
600 ร— 20 รท 100 = 120  โ†’  600 โˆ’ 120 = โ‚น480

๐Ÿ’ก Analogy: Discount condition coupon gate laga: minimum bill meet ayithe matrame coupon activate avuthundi.

๐Ÿ’ป Step 2: Python Code

bill = float(input("Enter bill amount: "))

if bill >= 500:
    discount = bill * 20 / 100
    bill = bill - discount

print(f"Final bill: โ‚น{bill:.2f}")

โœ… Output
Enter bill amount: 600
Final bill: โ‚น480.00

๐Ÿ” Line by line


CodeMeaning
float(input(...))Bill amount teesukovadam
if bill >= 500Minimum bill condition
bill * 20 / 10020 percent amount
bill - discountDiscount tharvatha final amount
print(...)if block bayata undi, so eppudu print avuthundi

โš ๏ธ Common Mistake Alert

โŒ Wrong: 20% ante direct ga โ‚น20 subtract cheyyadam

bill = 600
bill = bill - 20
print(bill)

Result:
580

โœ… Right: bill * 20 / 100 tho percentage amount calculate chesi subtract cheyyandi.

๐Ÿ’ก Bonus tip: Percentage formula: amount * percent / 100. Idi tarvatha anni problems lo kuda vastundi.

๐Ÿ“ Quick Recap

  • โœ”๏ธ Percentage = amount ร— percent รท 100
  • โœ”๏ธ Condition true ayithe matrame discount
  • โœ”๏ธ Discount ledu ante bill same untundi

๐Ÿ‹๏ธ Practice Problems

๐ŸŸข Easy: Bill โ‚น400 ayithe final amount entha? (discount untunda?)
Expected output: โ‚น400.00


๐ŸŸก Medium: โ‚น1000 bill meeda 18% GST add chesi total bill print cheyyandi.
Expected output: โ‚น1180.00


๐Ÿ”ด Challenge: Bill โ‚น500 or more ayithe 20% discount. Tarvatha โ‚น40 delivery charge add cheyyandi. Bill โ‚น600 ayithe final entha?
Expected output: โ‚น520.00


๐Ÿ’ฌ Mee answers comments lo share cheyyandi!

๐Ÿš€ Next: Day 5 โ€“ College Attendance Calculator

Follow @GeethuTalks and stay tuned! ๐Ÿ’›

โฌ…๏ธ Previous: Day 3 of Problem Solving Series In Python

check out our website for more resources

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

Leave a Comment