Ends in
00
days
00
hrs
00
mins
00
secs
SHOP NOW

🚀 $4.99 Claude Certified Architect Foundations CCA-F Practice Exams

Lesson 14 of 40
In Progress

Python Keywords

In Python, keywords are a set of special reserved words used to define the structure and rules of the language. They have specific purposes and should not be used as variable names, function names, or identifiers, as doing so will cause errors in your code.

Python Common Keywords

KeywordDescription
FalseBoolean value for “not true”
NoneRepresents a null or no value
TrueBoolean value for “yes” or true
andCombines two conditions, both must be true
asUsed when giving a module or object an alias
assertUsed for debugging; checks if a condition is true
breakExits a loop early
classUsed to define a class (for object-oriented programming)
defDefines a function
delDeletes a variable, list item, or object
elifElse if – adds another condition after if statements
elseWhat to do if all if or elif conditions are false
exceptDefines what to do when a specific error occurs
finallyA block of code that will always be executed, whether there is an exception or not
forStarts a loop that runs over items
fromUsed when importing specific arts from a module
ifRuns code only if a condition is true
importLoads a module into your code
inChecks if a value exists in a sequence (e.g. list, range, etc.)
isChecks if two values refer to the same object
lambdaCreates a small, anonymous function
nonlocalRefers to a variable in the nearest outer scope
notReverses a condition (True becomes False, and vice versa)
orCombines conditions; true if at least one condition is true
raiseForces an error to happen
returnSends a value back from a function
tryRuns code and watches for errors
whileStarts a loop that runs as long as a condition is true
withUsed to manage resources (e.g. files) safely
yieldReturns a value from a generator function

Skip to content