Python Variables
Store and reuse values with clear names.
On this page
The concept
A variable gives a value a name. Python creates it when you assign with =. Names are case sensitive, and a later assignment can replace the value.
Code example
Python
name = "Ada"
score = 91
print(name, score)Output
Ada 91
Follow the code
Open the walkthrough to inspect the example one step at a time.
Show guided walkthrough
Guided walkthroughReady
1
name = "Ada"2
score = 913
print(name, score)Follow the example
Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.
View the complete dry-run table
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Assign the string Ada to name. | name = "Ada" | — | |
| Assign the integer 91 to score. | name = "Ada", score = 91 | — | |
| Read both variables and send them to print. | name = "Ada", score = 91 | Ada 91 |
Behind the scenes
How Python processes this code
Python runs this source through its interpreter. It creates objects for values and resolves names as each statement runs.