Keywords

Python Keywords: The useful list

In Python, keywords are reserved words that have a specific meaning and purpose. These words cannot be used as identifiers for variables, functions, or any other user-defined items. In this blog post, we’ll explore Python keywords, providing a brief overview of each one.

Keywords

Table of Python Keywords

Here’s a table listing Python’s keywords along with a short description for each:

KeywordDescription
andLogical AND operator
asCreates an alias while importing a module
assertUsed for debugging purposes
asyncUsed to define asynchronous functions
awaitUsed to call an asynchronous function and wait for result
breakBreaks out of the current loop
classUsed to define a class
continueContinues to the next iteration of the loop
defUsed to define a function
delDeletes an object
elifElse if part of an if-else structure
elseElse part of an if-else structure
exceptUsed with exceptions, what to do when an exception occurs
FalseBoolean value, represents false
finallyUsed with exceptions, a block of code that will be run no matter if there’s an exception or not
forUsed to create a for loop
fromUsed to import specific parts of a module
globalUsed to declare a global variable
ifUsed to make a conditional statement
importUsed to import a module
inUsed to check if a value is present in a sequence
isUsed to test if two variables are the same object
lambdaUsed to create an anonymous function
NoneRepresents a null value
nonlocalSimilar to the global keyword but has a different scope
notLogical NOT operator
orLogical OR operator
passA null statement, a place where no action occurs
raiseUsed to raise an exception
returnUsed to return a value from a function
TrueBoolean value, represents true
tryUsed to catch exceptions
whileUsed to create a while loop
withUsed to simplify exception handling
yieldUsed to end a function and returns a generator
Keywords

Conclusion

Python’s keywords are the building blocks of the language, each serving a unique purpose in various aspects of programming. Understanding these keywords and their functions is essential for anyone learning or working with Python.