Python Keywords and Identifiers
Python Keywords
Keywords are the reticent words in Python.We can not use a keyword as a variable name, function name or any different identifier. They're applied to define the syntax and edifice of the Python vocabulary.
In Python, keywords are case sensitive.
There are 33 keywords in Python3.7. This number can vary marginally over the course of time.
Python Identifiers
An identifier is a name given to realities like class, functions, variables, etc. It helps to separate one reality from another.
Rules for writing identifiers:
1.Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or integers (0 to 9) or an underscore,. Names like myClass,var_1 andprint_this_to_screen, all are valid illustration.
2.An identifier can not start with a number. 1variable is invalid, but variable1 is a valid name.
3.Keywords can not be used as identifiers.
global = 1
Affair
Train"", line 1
. global = 1
SyntaxError invalid syntax
Affair
Train"", line 1
. global = 1
SyntaxError invalid syntax
4.We can not use special symbols like!,@,#,$,etc. in our identifier.
a@ = 0
Affair
Train"", line 1
. a@ = 0
SyntaxError
Affair
Train"", line 1
. a@ = 0
SyntaxError
5.An identifier be of any length.
Comments
Post a Comment