Identifire Rules In Python
For Beginners and Professionals |
Identifier means "name" we give to variables ,methods or class. there are some rules to give name to identifiers in python.
identifier example : x=10 , def test() , class Demo
In this example x is variable name, test is method name, Demo is class name , called as Identifier.
Rule :
We can use both Uppercase and Lowercase Alphabets.
We can use digit 0 to 9
We can use _(Underscore)
Other than this if we use anything while giving name to identifier we will get error message
Example : cash=10 ==== correct
ca$h=10 ==== incorrect
total123=10 ====correct
123total=10 ==== incorrect
Note : Identifier should not start with numbers.
total=10 ==== correct
TOTAL=10 ==== correct
Total=10 ==== correct
TOtaL=10 ==== Correct
Note - There is no max limit for python identifier. If identifier starts with starts with ( _ ) underscore
then it considered as Private. and Two underscore ( _ _ ) strongly private .
_ _main_ _ starts and ends with two underscore symbol then it considered as language specific
Comments
Post a Comment