Python Keywords

Python Keywords

Python has a set of reserved keywords that have special meanings in the language.

These keywords cannot be used as identifiers like: variable names, function names, class names, etc.

The following table details all of the Python keywords with links to respective tutorials for the keywords.

Keyword Description Tutorial
and A logical operator Python logical AND operator
as To create an alias Python AS keyword
assert For debugging Python ASSERT keyword
break To break out of a loop Python break
class To define a class Python class
continue To continue to the next iteration of a loop Python continue
def To define a function Python Function
del To delete an object Python del
elif Used in conditional statements, same as else if Python elif
else Used in conditional statements Python if else
except Used with exceptions, what to do when an exception occurs Python Try Except
False Boolean value, result of comparison operations Python False
finally Used with exceptions, a block of code that will be executed no matter if there is an exception or not. Python finally
for To create a for loop Python For loop
from To import specific parts of a module Python from
global To declare a global variable Python global variable
if To make a conditional statement Python if
import To import a module Python import
in To check if a value is present in a list, tuple, etc., or to iterate over a collection in For loop syntax. Python in keyword
is To test if two variables are equal Python is
lambda To create an anonymous function Python Lambda Function
None Represents a null value Python None
nonlocal To declare a non-local variable
not A logical operator Python NOT logical operator
or A logical operator Python OR logical operator
pass A null statement, a statement that will do nothing Python pass
raise To raise an exception Python raise
return To exit a function and return a value Python return
True Boolean value, result of comparison operations Python True
try To make a try…except statement Python Try Except
while To create a while loop Python While loop
with Used to simplify exception handling Python with
yield To end a function, returns a generator Python yield

Frequently Asked Questions

1. What are Python keywords?

Answer:

Keywords are a kind of reserved literals that have special meanings in the Python language. Some of these python keywords are: and, as, assert, break, class, continue, etc.

2. How many keywords are there in Python?

Answer:

There are about 35 keywords in Python.

3. What are the 35 keywords in Python?

Answer:

The 35 keywords in Python are: False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, , for, from, global, if, import, in, is, lambda, , not, or, pass, raise, return, try, while, with, yield

Related Tutorials

Privacy Policy Terms of Use

SitemapContact Us