Python Keywords
Python keywords are reserved words with specific functions and restrictions in the language. Currently, Python has thirty-five keywords and four soft keywords. These keywords are always available in Python, which means you don’t need to import them. Understanding how to use them correctly is fundamental for building Python programs. They cannot be used as variable names, function names, or identifiers.
Total Keywords in Python
Python has 35 keywords (in modern Python versions).
Python Keywords
| S No. | Keyword | Purpose |
| 1 | False | Boolean false value |
| 2 | None | Represents no value |
| 3 | True | Boolean true value |
| 4 | and | Logical AND operator |
| 5 | as | Creates alias |
| 6 | assert | Debugging check |
| 7 | break | Exits a loop |
| 8 | class | Defines a class |
| 9 | continue | Skips current loop iteration |
| 10 | def | Defines a function |
| 11 | del | Deletes an object |
| 12 | elif | Else if condition |
| 13 | else | Executes when if is false |
| 14 | except | Handles exceptions |
| 15 | finally | Runs after try-except |
| 16 | for | Looping statement |
| 17 | from | Imports specific parts |
| 18 | global | Declares global variable |
| 19 | if | Conditional statement |
| 20 | import | Imports a module |
| 21 | in | Checks membership |
| 22 | is | Tests object identity |
| 23 | lambda | Creates anonymous function |
| 24 | nonlocal | Refers to outer function variable |
| 25 | not | Logical NOT |
| 26 | or | Logical OR |
| 27 | pass | Empty statement |
| 28 | raise | Raises exception |
| 29 | return | Returns value |
| 30 | try | Handles errors |
| 31 | while | Looping statement |
| 32 | with | Used for resource management |
| 33 | yield | Returns generator value |
| 34 | match | Pattern matching |
| 35 | case | Used in match statements |
Example
if age > 18: # if is a keyword
return True # return and True are keywords