Keywords and Identifier in Python?

Keywords and Identifier in Python

Keyword/Reserved Words in Python:

In Python, we cannot use a Reserved word as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. 

In Python, Reserved words are case-sensitive. There are 35 keywords in Python 3 to the date of post. All the keywords except True, False, and None are in lowercase and must be written in lowercase

There are following Reserved words in Python:

[‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘async’, ‘await’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]

To directly checklist of reserved word/keyword go to python interpreter and type the following code :

>>>import keyword


This code will print all keyword/reserved words of python.


An identifier in python used to identify a variable function, class, module, or any other objects. Python is case sensitive so uppercase and lowercase letter are considered distinct(different). 

Following Rules are used for naming an identifier in python:

  • Python Identifier can be a combination of letters in lowercase(a-z) uppercase(A-Z) or digits(0-9) or an underscore ( _ ). Eg- Ram, and ram is treated differently in python because it is case sensitive programming language
  • Reserved keywords cannot be used as identifiers.
  • Identifiers cannot begin with a digit(0-9). Eg- 0atom, 9Hero, 2times, 2person, etc.
  • Special Symbols ( @, !, #,$, %etc ) cannot be used in identifier Eg- #raj , monty@ , b@nty, etc is invalid identifiers
  • An identifier can be of any Length

Naming Convention in Python:

  • Class names start with an uppercase letter and all other identifiers start with a lowercase Eg- People, Person, etc
  • Identifier name start with a single leading underscore ( _.. ) indicates that the identifier is Private Eg- sum, _name, _ram, etc.
  • Identifier name starts with Double leading underscore ( __.. ) indicates that the identifier is Strongly Private Eg- sum, __name, __ram, etc.
  • Identifier name Ending with Double trailing underscore ( ..__ ) indicates that the identifier is a Language-defined special name Eg- sum, name, ram__, foo__, etc

Keywords and Identifier in Python

View Our Article On Python

View Our Latest Article


1 comment

Leave a Reply

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

%d bloggers like this: