Keywords are those words having fixed meaning in python interpreter. In Python list of all the keywords shown below:
and | del | from | None | try |
as | elif | global | nonlocal | True |
assert | except | import | or | while |
break | else | if | not | with |
class | False | in | pass | yield |
continue | finally | is | raise | return |
def | for | lambda |
Identifiers
Identifier is the name set to variables, class, functions, etc. Identifier is the combination of alphabet letters i.e. uppercase (A to Z) and lowercase (a to z), digits (0 to 9), and the special character _ (underscore).
For example:
The statement in python is given by
sum=100
Indicate that:
- 100 is the value assign to variable sum.
- sum is identifier.
Rules for defining identifiers
- An alphabet or underscore used in the starting letter of identifiers.
For example:
_sum=1 sum_amount=10
Here, _sum and sum_amount both are valid identifiers.
- An identifier cannot be keywords or standard function name.
For example:
else=10
Here, else invalid identifier because else is keyword.
- An identifier can have any length allowed in Python.
- Only underscore in special characters is allowed.
For example:
sum_amount=10
Here sum_amount is a valid identifier.
- Identifiers are case sensitive i.e. uppercase letters and lower case letters are different.
For example:
sum=10 Sum=10
Here sum and Sum both are different identifiers.