CurriculumWriting Clean Python Code, for KidsNaming as a thinking tool
Why Variable Names Matter in Python (Even Though Python Doesn't Care)
A name never changes what code DOES — only whether a human can tell what it's FOR.
Naming as a thinking tool
Every level so far, names like x, y, and z would have worked just as well as health or gold. Let's see that directly.
x, y, z — terrible names, but watch the output.
x = 100
y = 30
z = x - y
print(z)Output
70Same exact math, real names this time. Same output.
health = 100
damage = 30
remaining_health = health - damage
print(remaining_health)Output
70Python genuinely does not care what anything is called — it ran the SAME subtraction both times and got the SAME 70.
So what does a name actually change? Whether a human — you, in six months, or someone reading your code — can tell what it's FOR without re-figuring it out.
A good name answers 'what is this' at a glance. remaining_health tells you immediately; z tells you nothing at all.
Check your understanding
x = 100, y = 30, z = x - y vs. health = 100, damage = 30, remaining_health = health - damage. Do these two programs behave differently when run?
x = 100
y = 30
z = x - y
print(z)Why: No difference at all — both compute 100 - 30 and print 70. Python has no concept of what a name 'means' in English; it just needs SOME label to refer to a value by. The only thing that changes with better names is how easily a human can follow the code.
If naming never changes what a program actually DOES, why does it matter at all?
Why: Because code is read by humans far more often than it's run by a computer's concern for correctness. z = x - y and remaining_health = health - damage run identically, but only one of them tells a reader what's actually happening without extra work — that's the entire value of a good name.
What you'll practice
Run this code exactly as it is. x, y, and z are terrible names — but predict the OUTPUT anyway. Does bad naming change what the code actually computes?
More from this topic
Naming as a thinking tool is one lesson inside Writing Clean Python Code, for Kids — see the full lesson order and what the whole topic covers.
View the full topic →