Python Variable Name Rules
What are Variable Name Rules in Python?
Python is not a "statically typed" programming language. We don't need to define variables or their types before utilizing them. When initially a value is assigned to a variable, it is said to be created.
A memory region is given a name called a variable. It is a program's fundamental storage unit.
The following are the rules for defining variables in Python:
-
A variable's name must begin with a letter or a single underscore.
-
The initial character in a variable name cannot be a number.
-
In variable names, only alpha-numeric characters and underscores (A-z, 0-9, and _) are permitted.
-
When it comes to variable names, the character case matters (name, Name, and NAME are three different variables).
-
The use of reserved terminology (keywords) in the variable's name is prohibited.
Example :
1x wrong variable
#name wrong variable
__x wrong variable
.x wrong variable
X. wrong variable
X1 right variable
X_ right variable
_x right variable
It’s Quiz Time!
