Python Keywords

  • Python keywords are reserved words that have special meanings in the Python programming language. These words are part of Python’s syntax and cannot be used as variable names, function names, or identifiers. Examples of Python keywords include if, else, for, while, True, False, None, class, and def.


  • What Are Keywords in Python? 

    Keywords are special reserved words in Python that have a fixed meaning and purpose in the language.

    You cannot use keywords as:

    • variable names

    • function names

    • class names

    • identifiers

    because Python uses these words to define its syntax and structure.

    Important points:

    • Keywords are predefined by Python.

    • They are used to define the logic, conditions, loops, functions, etc.

    • Keywords are case-sensitive (must be lowercase except True, False, None).

    You cannot change their meaning.

    Why keywords are important?

    Because Python uses them to understand:

    • decisions (if, else)

    • loops (for, while)

    • errors (try, except)

    • functions (def, return)

    • classes (class)

    • Boolean values (True, False)

    • nothing value (None)


Note:

 Without keywords, Python code cannot work.


  • Total Keywords in Python

    As of Python 3.12, Python has 35 keywords.

    Python Keywords


    Keyword

    Meaning / Use

    False

    Boolean false value

    True

    Boolean true value

    None

    Represents no value / null

    and

    Logical AND operator

    or

    Logical OR operator

    not

    Logical NOT operator

    if

    Conditional statement

    elif

    Else-if condition

    else

    Final condition in if-block

    for

    Loop through a sequence

    while

    Loop until condition becomes false

    break

    Exit a loop

    continue

    Skip current loop iteration

    pass

    Do nothing (empty block)

    def

    Define a function

    return

    Return value from a function

    class

    Define a class

    from

    Import specific items

    import

    Import modules

    as

    Rename imported module

    try

    Start exception-handling block

    except

    Handle exception

    finally

    Always executes (cleanup code)

    raise

    Raise an exception

    assert

    Debugging check

    lambda

    Create a small anonymous function

    del

    Delete an object

    in

    Check membership in a sequence

    is

    Check identity (same object)

    with

    Easy resource management

    global

    Declare a global variable

    nonlocal

    Use variable from outer function

    async

    Define asynchronous function

    await

    Wait for async result

    yield

    Produce a generator value


  • What Are Keywords in Python?

    Keywords are special reserved words in Python that have a predefined meaning and play a specific role in the language.
    These words are part of Python’s core syntax, so you cannot use them as:

    • variable names

    • function names

    • class names

    • identifiers

    Python relies on keywords to understand the structure of your code.

    Key Characteristics of Keywords

    • Predefined by Python — you cannot create or modify them.

    • Used to build logic — conditions, loops, functions, exceptions, classes, etc.

    • Case-sensitive — most are lowercase, except True, False, and None.

    • Cannot be reassigned — their meaning cannot be changed.

    Why Are Keywords Important?

    Keywords are the building blocks of Python programs.
    Python uses them to interpret:

    • Decisions: if, elif, else

    • Loops: for, while

    • Error handling: try, except, finally

    • Functions: def, return

    • Classes: class

    • Boolean values: True, False

    • Empty values: None


Note:

Total Python keywords: 35 , Keywords are case-sensitive , you cannot redefine keywords