1.2.3 · HinglishIntroduction to Programming (Python)
Variables — naming rules, assignment, reassignment
1.2.3· Coding › Introduction to Programming (Python)
Variable KYA hota hai?
Assignment KAISE kaam karta hai
Right-to-left kyun? Kyunki value ka pehle exist karna zaroori hai, tabhi koi naam use point kar sakta hai. Kuch nahi pe label nahi lagate.
Reassignment KAISE kaam karta hai

Naming RULES (maanne zaroori hain — warna SyntaxError)
Steel-man: common mistakes
Flashcards
Python mein = operator kya karta hai?
Right-hand expression ko ek object mein evaluate karta hai, phir left-hand naam ko us object se bind karta hai (assignment, equality nahi).
name = expression kis order mein process hota hai?
Right-to-left: pehle expression evaluate hota hai, phir naam bind hota hai.
Python mein x = x + 5 valid kyun hai?
= assignment hai; x ki purani value result compute karne mein use hoti hai, phir x naye object se rebind hota hai.a=100; b=a; a=200 ke baad b kya hai?
100 —
b abhi bhi original object ko label karta hai; a ko reassign karne se sirf a ka reference move hua.Kya variable naam digit se shuru ho sakta hai?
Nahi. Yeh letter ya underscore se shuru hona chahiye.
Kya Age aur age same variable hain?
Nahi — Python identifiers case-sensitive hote hain.
Variable naam mein teen forbidden cheezein batao.
Digit se shuru karna, spaces/symbols jaise
- @, aur reserved keywords.Naam ko assign karne se pehle use karne par kya error aata hai?
NameError: name '...' is not defined.
Reassignment PURANE object ke saath kya karta hai?
Kuch nahi — naam bas use point karna band kar deta hai; agar unreferenced ho toh garbage-collect ho jaata hai.
Constant naam rakhne ki convention kya hai?
ALL_CAPS, jaise
MAX_SPEED = 120.Recall Feynman: 12-saal ke bachche ko samjhao
Socho naam sticky labels hain aur values toys hain. score = 10 bolne se ek toy "10" banta hai aur label score use chipka deta hai. score = 20 bolne se purana toy nahi badlata — label ukhad ke ek naye toy "20" pe chipak jaata hai. Agar tumhare dost ne pehle toy pe ek label copy chipkaya tha, toh unka label abhi bhi toy "10" pe hai chahe tumne apna move kar liya ho. = sign yeh nahi kehta "yeh barabar hain" — yeh kehta hai "jao yeh label yahaan chipkao."
Connections
- 1.2.01-Data-Types — woh objects jinhe variables point karte hain.
- 1.2.02-Operators —
=(assign) vs==(compare). - 1.2.04-Mutable-vs-Immutable — kyun
b=aints ke liye safe hai lekin lists ke liye tricky. - 1.2.05-Namespaces-and-Scope — naam kahaan rehte hain.
- 1.1.00-Memory-and-References — heap objects aur garbage collector.