Python Variables
Variables are labeled storage containers in your program memory. If you put sugar into a jar labeled "sugar", you can grab it whenever you need sweetness. In Python, you write user_name = "Alex", and Python holds onto it until you decide to update it.
"Think of variables as named cardboard moving boxes. You write a name on the outside in Sharpie ("high_score"), toss a value inside (9500), and whenever you ask Python for "high_score", it opens the box and hands you the 9500."
Deep Dive: How It Works
Variables in Python are dynamically typed. That means you do not need to explicitly declare if a variable holds text or a number ahead of time. Python inspects the value you assign and assigns the type under the hood.
The single equal sign (=) is the assignment operator. It tells Python to evaluate whatever is on the right side first, and store the result into the label on the left side.
Variable names in Python follow snake_case convention: all lowercase letters with words joined by underscores (e.g. max_speed, user_email). Names must start with a letter or underscore, and cannot start with a number or contain spaces.
Syntax Blueprint
variable_name = value
The label is on the left, the single equal sign acts as the assignment arrow, and the value is on the right.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Putting the value on the left side: 100 = scoreWhy it happens: In math, 100 = x is valid, but in programming the container name must always be on the left.
How to fix: Always write container_name = value (e.g. score = 100).
Using reserved Python keywords as namesWhy it happens: Naming a variable "print", "class", or "for" breaks Python syntax.
How to fix: Choose descriptive custom names like current_print_job or user_class.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Create and print a variable
Create a variable called language and assign it the string value "Python".
Then print the language variable.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.