Keywords:
These keywords serve various purposes in python as below:
– Control Flow: Keywords like if, else, elif, for, while, break, continue, and pass are used for control flow statements and loops.
– Function and Class Definitions: Keywords such as def and class are used to define functions and classes respectively.
– Logical Operators: Keywords like and, or, not are used as logical operators for Boolean expressions.
– Exception Handling: Keywords such as try, except, finally, raise are used for exception handling.
– Importing Modules: Keywords like import and from are used to import modules and packages into the Python script.
– Boolean Values: Keywords True and False represent the Boolean values in Python.
It is important to note that keywords are case-sensitive and cannot be used as variable names or identifiers in Python programs.
Attempting to use a keyword as an identifier will result in a syntax error as below:
Total number of keywords : 35. These are as below:
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