Basic Syntax
Python Keywords
Reserved words in Python
Interview: Language fundamentals
Python has 35 reserved keywords that cannot be used as variable, function, or class names. They form the structural backbone of Python syntax. Understanding each keyword's purpose is fundamental to writing correct Python code.
Control Flow Keywords
if,elif,else— conditional branchingfor,while— loopsbreak,continue,pass— loop controlmatch,case— structural pattern matching (Python 3.10+)
Definition Keywords
def— define a functionclass— define a classreturn,yield— return values from functions/generatorslambda— anonymous functionasync,await— asynchronous programming
Import & Module Keywords
import,from,as— module importsglobal,nonlocal— variable scope control
Error Handling & Context
try,except,else,finally,raise— exception handlingwith— context managers (resource management)assert— debugging assertionsdel— delete references
Special Values
True,False— boolean valuesNone— null/absence of valueand,or,not,in,is— logical and identity operators
Soft Keywords (Python 3.10+)
match and case are "soft keywords" — they only have special meaning inside a match statement. You can still use them as variable names elsewhere (though it's not recommended).
Use Cases
Understanding Python language structure for debugging
Avoiding naming conflicts with reserved keywords
Writing correct control flow and error handling
Using scope control keywords (global, nonlocal) properly
Common Mistakes
Accidentally using a keyword as a variable name (SyntaxError)
Confusing global vs nonlocal for nested function scope
Not understanding pass vs continue vs break in loops
Using lambda when a proper def would be more readable