A Python variable is simply a name (a label) you use to refer to a value (the information). It allows you to store, retrieve, and change data in your program in an organized way.
Creating Variables
Creating a variable is simple in Python. You just give it a name and use the equals sign (=) to put a value inside the “box”.
Syntax (The Rule):variable_name = value
Example
What it does (Box Analogy)
age = 30
Creates a box labeled age and puts the number 30 inside.
name = "Sara"
Creates a box labeled name and puts the text “Sara” inside.
is_sunny = True
Creates a box labeled is_sunny and puts the value True inside.
Variable Names
A variable can have a short name (like a and b) or a more descriptive name (age, name, total_number).
Golden Rules for Naming Variables
A variable name must start with a letter or the underscore character.
A variable name cannot begin with a number.
A variable name can only contain alphanumeric characters and underscores (A-z, 0-9, and _).
Variable names are case-sensitive (e.g., age, Age, and AGE are three different variables).
Cannot be one of Python’s reserved words (like if, for, while, etc.).