The objective of this topic is to get familiar about the Python keywords, identifiers and variables. These are the basic building blocks of Python programming. Hence, we must know everything about them.
Python keyword is a unique programming term intended to perform some action. There are many keywords in Python, each serving a different purpose. Together, they build the vocabulary of the Python language.
Keywords are special words that are reserved and have a specific meaning. Python has a set of keywords that cannot be used as variables in programs.
All keywords in Python are case sensitive. So, we must be careful while using them in our code.
Note: Number of keywords may change from version to version as python is constantly improving so with the new version we may have new keywords
To know the list of keywords in your current version
>>>import keyword >>>print(keyword.kwlist) ['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']
It’s a long list to remember all at once. Our purpose of mentioning it here is only to give you an initial idea of the available keywords. However, we’ll cover each of them later.
we don’t need to memorize them instead we will learn to use them step by step.
One very important point to remember is that the above list may change. The language could get away with some of the old keywords and bring in new ones in future releases.
Another method know the list of keywords in your current version
>>>help() >>>help> keywords Here is a list of the Python keywords. Enter any keyword to get more help. False class from or None continue global pass True def if raise and del import return as elif in try assert else is while async except lambda with await finally nonlocal yield break for not help>
Only the following keywords have the first character as capital rest all the keywords are written in small case.