Variable
A name that refers to a stored value, so you can reuse it by name.
You create a variable with the assignment operator =: the name on the left starts referring to the value on the right. The same name can be reassigned at any time, and it can hold any type of value — text, a number, a list, and so on.
Names may contain letters, digits, and underscores, cannot start with a digit, and are case-sensitive — age and Age are two different variables.
age = 30 # bind the name "age" to the value 30
name = "Ada" # a name can hold any type of value
age = age + 1 # reassign: "age" now refers to 31
print(name, age)
Output
Ada 31
Where this shows up in real Python
Variables are everywhere: storing user input, counting progress in a loop, holding an API response, or remembering a filename to write to later.
Commonly used Variable tools
A variable isn’t a class with methods, but a few built-ins inspect what a name points to:
type(value)— show what kind of object a name points toisinstance(value, int)— check whether it points to a given typedel name— remove a name so it no longer points to anything
Official documentation: Python Language Reference: Assignment statements