strf = format object→string; strp = parse string→object
Why use os.path.join instead of string +?
It uses the correct OS separator → portable code
Why time.perf_counter() over time.time() for timing?
Highest-resolution monotonic clock; never jumps backward
Size of permutations(n, r)?
n!/(n−r)!
Size of combinations(n, r)?
(rn)=n!/(r!(n−r)!)
What does functools.reduce(f,[a,b,c]) compute?
f(f(a,b),c) — left-fold accumulation
What does lru_cache do for recursive fib?
Memoizes results → turns O(2n) into O(n)
Why pass list not list() to defaultdict?
defaultdict calls the factory itself when a key is missing
What is sys.argv[0]?
The script's own name
Why is deque.popleft() better than list.pop(0)?
O(1) vs O(n) (no shifting)
Recall Feynman: explain to a 12-year-old
Imagine a huge toolbox that comes free with your bike. One drawer (math) has number gadgets, one (random) is a dice cup, one (os) talks to your computer about files, one (collections) has magic boxes that count things by themselves, and one (itertools) is a machine that makes every possible combination of your stickers without you doing it by hand. You don't need to make these tools — they're already in the box. You just need to know which drawer to open.
Dekho, Python ki sabse badi taakat hai uska standard library — yeh ek aisa toolbox hai jo Python install karte hi free mein milta hai, kuch alag se download nahi karna padta. Soch lo har module ek drawer hai jisme ready-made, tested aur C-fast functions bhare pade hain. Aapko har function ratne ki zaroorat nahi — bas yeh yaad rakho ki kaun sa kaam kaunse drawer mein hai. Yahi 80/20 rule hai: thoda map yaad karo, bahut saara kaam ho jayega.
Quick tour: math single numbers ke liye (sqrt, comb, gcd), random dice/chance ke liye (aur seed se same sequence dobara aata hai — testing mein bahut kaam ka), os files aur folders ke liye, sys Python interpreter se baat karne ke liye (jaise sys.argv command-line arguments). datetime calendar dates ke liye aur time timing/sleep ke liye — yeh do alag cheezein hain, confuse mat hona.
collections mein superpowers wale containers hain: Counter cheezein automatic gin leta hai, defaultdict missing key par error nahi deta, aur deque dono taraf se O(1) mein add/remove karta hai. itertools lazy hota hai — matlab on-demand items banata hai, isliye combinations aur permutations jaise combinatorics problems isse mast solve hote hain. Aur functools mein lru_cache hai jo recursive fibonacci ko O(2n) se O(n) bana deta hai — magic memoization!
Yeh isliye matter karta hai kyunki interviews aur real projects mein log apna code chhota aur reliable rakhte hain — wheel dobara nahi banate. Jab aap sahi drawer khol lete ho, aapka code chhota, fast aur bug-free ho jaata hai.