Tokens
A token is the smallest element of a Python script that is meaningful to the interpreter.
The following categories of tokens exist:
keywords, identifiers/variables, operators, and delimiters.
Python Keywords
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>
Note:
Only the following keywords have the first character as capital rest all the keywords are written in small case.
None
True
False