Python · Course navigation

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
1name = "Ada"
2score = 91
3print(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
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput 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.