Keywords and Identifiers in Python
Keywords and Identifiers
Keywords
Keywords are the reserved words in Python. They convey a special meaning to the compiler. Keywords are reserved for special purpose so We cannot use a keyword as a variable name , function name or any other identifier.
Identifiers
Identifiers are the names used to identify things in your code. An identifier is a user-defined name to represent a variable, a function, a class, a module, or any other object. Any word that has not been commented out, delimited by quotation marks, or escaped in some other way is treated as an identifier by Python .
Rules for writing identifiers
1. A Python identifier can be a combination of uppercase/lowercase letters, digits, or an underscore. The following characters are valid:
Lowercase letters (a to z)
Uppercase letters (A to Z)
Digits (0 to 9)
Underscore (_)
For example,
Name1,first_name,LASTNAME,_NAME
Are valid identifiers.
But following are not valid identifiers:
"First-name" as it contains “-“"First name" as it contains space
|First.name" as it contains “.”
Comments
Post a Comment