Python Keywords
Python keywords are reserved words that have a predefined meaning in the language. These keywords cannot be used as variable names, function names, or any other identifiers. They form the core syntax of Python and are essential for writing Python programs.
List of Python Keywords
Keyword | Description |
---|---|
False | Represents the boolean value false. |
None | Represents a null value or absence of a value. |
True | Represents the boolean value true. |
and | Logical AND operator. Returns True if both conditions are True. |
as | Used to create an alias when importing a module. |
assert | Used for debugging; tests if a condition is true. |
async | Defines an asynchronous function (introduced in Python 3.5). |
await | Pauses execution of an async function until the awaited task is complete. |
break | Exits the loop prematurely. |
class | Defines a new class. |
continue | Skips the current iteration of a loop and moves to the next iteration. |
def | Defines a function. |
del | Deletes an object or variable. |
elif | Else-if condition in conditional statements. |
else | Specifies a block of code to run if conditions are false. |
except | Handles exceptions in a try-except block. |
finally | A block of code that always executes, even if an exception occurs. |
for | Used for looping over a sequence. |
from | Used for importing specific parts of a module. |
global | Declares a global variable inside a function. |
if | Starts a conditional statement. |
import | Imports a module into the script. |
in | Checks if a value exists within a sequence. |
is | Checks if two variables reference the same object. |
lambda | Defines an anonymous function. |
nonlocal | Declares a non-local variable in a nested function. |
not | Logical NOT operator. Returns the opposite boolean value. |
or | Logical OR operator. Returns True if at least one condition is True. |
pass | A placeholder statement that does nothing. |
raise | Raises an exception. |
return | Returns a value from a function. |
try | Begins a block for exception handling. |
while | Starts a loop that runs as long as a condition is true. |
with | Simplifies exception handling in context management. |
yield | Pauses and resumes a function, producing a generator. |