Appendix A — Built-In Keywords
The following table provide a complete list of the built-in keywords and functions in Python. An online version with clickable definitions is available here.
Keyword | Description |
---|---|
and |
A logical operator |
as |
To create an alias |
assert |
For debugging |
break |
To break out of a loop |
class |
To define a class |
continue |
To continue to the next iteration of a loop |
def |
To define a function |
del |
To delete an object |
elif |
Used in conditional statements, same as else if |
else |
Used in conditional statements |
except |
Used with exceptions, what to do when an exception occurs |
finally |
Used with exceptions, will be executed no matter what occurs |
for |
To create a for loop |
from |
To import specific parts of a module |
global |
To declare a global variable |
if |
To make a conditional statement |
import |
To import a module |
in |
To check if a value is present in a list, tuple, etc. |
is |
To test if two variables are equal |
lambda |
To create an anonymous function |
nonlocal |
To declare a non-local variable |
not |
A logical operator |
or |
A logical operator |
pass |
A null statement, a statement that will do nothing |
raise |
To raise an exception |
return |
To exit a function and return a value |
try |
To make a try…except statement |
while |
To create a while loop |
with |
Used to simplify exception handling |
yield |
To return a list of values from a generator |