1. python-keywords

Python Keywords

Keywords are the reserved words used in Python programming language. These keywords have special meaning and cannot be used as variable names or function names in a program. In Python, keywords are case-sensitive.

Here's the list of Python Keywords:

and       as        assert    break 
class     continue def       del 
elif      else      except    False 
finally  for       from      global 
if        import    in        is 
lambda    None      nonlocal  not 
or        pass      raise     return 
True      try       while     with 


There is no syntax for Python keywords as they are already built-in.


Here are some examples of Python keywords used in code:

# defining a function
def greet(name):
    print(f"Hello, {name}!")

# using if-else keyword in conditional statement
x = 5
if x > 10:
    print("x is greater than 10")
    print("x is less than or equal to 10")

# for loop with the help of a keyword
for i in range(1, 6):


Python keywords are used to create blocks of code, such as if-else statements, loops, and functions. These keywords modify the flow of the code, define functions, classes, and variables, and handle exceptions. For example, the if keyword is used to create a conditional statement, while the def keyword is used to define a function. The in keyword is used to check if a value is present in a sequence or not.


It is important to remember that Python keywords cannot be used as variable names, function names, or any other identifier names in the program. They can, however, be used as dictionary keys, class instance variables, or module names.

Important Points

  • Python keywords are case-sensitive.
  • The None keyword represents a null value in Python.
  • The try and except keywords are used for exception handling in Python.
  • Keywords like True and False are used to represent boolean values.


Python keywords are built-in reserved words that have a special meaning and cannot be used as variable names or function names. They are case-sensitive. Some of the keywords are if, else, for, while, and, or, def, class, try, except, True, and False. It is important to not use these keywords as variable or function names in your program to avoid syntax errors.

Published on: