Default Parameter Values in Python Functions
Learn how to set default values for function parameters, the rules for ordering required and optional parameters, and how to avoid mutable default value pitfalls.
Learn Python programming from scratch
Learn how to set default values for function parameters, the rules for ordering required and optional parameters, and how to avoid mutable default value pitfalls.
Learn how *args lets Python functions accept any number of positional arguments, how it works under the hood as a tuple, and when to use it in your own functions.
Learn how **kwargs lets Python functions accept any number of keyword arguments, how it works as a dictionary, and how to combine it with *args for maximum flexibility.
Learn how to enforce calling conventions with the / and * syntax in Python function signatures, making parameters positional-only or keyword-only.
Understand how Python passes objects to functions, the difference between passing mutable and immutable types, and how to avoid accidental data modification.
Learn the difference between pure functions and impure functions, why purity matters for testing and reliability, and how to write more pure functions in Python.
Learn how lambda functions work in Python, when to use them for short anonymous operations, and when a regular named function is the better choice.
Learn how recursive functions work in Python, including base cases, the call stack, recursion depth limits, and when to choose recursion over iteration.
Learn how to define functions inside other functions in Python, why nesting is useful for encapsulation and factories, and how inner functions access outer variables.
Learn what closures are in Python, how they capture variables from enclosing scopes, and how to use them for function factories, callbacks, and state encapsulation.
Learn how to annotate function parameters and return values in Python, what annotations are used for, and how they improve code readability and tooling support.
Learn how to write effective docstrings for Python functions, the PEP 257 conventions, and how tools like help() and Sphinx use them to generate documentation.