Lesson — Foundation
GINTEE
PYTHON SE.
Run-rate, bill split, interest, percentage — har hisaab ke peeche teen number types aur kuch operators hain. Is lesson ke baad koi formula nahi rokega.
WHY: har hisaab number hai
Cricket run-rate, Swiggy bill split, bank interest, marks percentage — har calculation ke peeche Python numbers hain. Teen types samajh lo, phir koi formula nahi rokega.
runs = 186
balls = 120
overs = balls / 6
print(runs / overs) # 9.3 run-rate
print(7 / 2) # 3.5 (divide)
print(7 // 2) # 3 (floor — dashamlav kata)Poora number: 10, -3. Count, index, quantity.
Decimal: 9.99, 3.14. Price, average, percentage.
// floor divide, % remainder, ** power — teeno MNC favourite.
HOW: operator chunna
Poora division chahiye to /, sirf poora hissa chahiye to //, bacha hua chahiye to %. Paise ka hisaab float me karo, count int me. round(9.99, 1) decimal control karta hai.
bill = 1000
friends = 3
print(bill // friends) # 333 har ek
print(bill % friends) # 1 bacha
print(round(10 / 3, 2)) # 3.33Quick check
7 // 2 ka output kya hoga?
Double slash decimal kaat deta hai — sirf poora hissa bachta hai.
0.1 + 0.2 exact 0.3 nahi hota (binary fraction). Paise ka hisaab hamesha soch-samajh kar.print(0.1 + 0.2) # 0.30000000000000004!
print(10 % 3) # 1 (remainder)
print(2 ** 10) # 1024MNC tip: Float wala fact bol do — interviewer samjhega depth hai.
Common mistakes
/aur//mix karna — bill split me galat total.- Paise ko
floatme compare karna (0.1 + 0.2exact nahi hota) — paise ko paise me ginna seekho. %ko percentage samajhna — Python me ye remainder hai.
Ab text numbers ko aur powerful banao — strings par wapas chalo.