A variable is used to store data that will be used by the program. This data can be a number, a string, a Boolean, a list or some other data type. Every variable has a name which can consist of letters, numbers, and the underscore character
The equal sign
= is used to assign a value to a variable. After the initial assignment is made, the value of a variable can be updated to new values as needed.
A variable can have a short name (like
y) or a more descriptive name (
Rules for Python variables:
- A variable name must start with a letter or the underscore character. It cannot start with a number.
- A variable name can only contain alpha-numeric characters and underscores (
- Variable names are case-sensitive (
NUMare three different variables).
These are all valid variable names and assignment:
user_name = "@sonny420"user_id = 100verified = False
A variable’s value can be changed after assignment