Skip to content
    Hack The FutureHack The FuturePython Notes

    UNIT 03 · TOPIC 07

    Anonymous Functions (Lambda)

    A lambda expression creates a small anonymous function, often used as a short key or callback.

    The idea

    Anonymous Functions (Lambda), simply explained

    A lambda expression creates a small anonymous function, often used as a short key or callback.

    01

    See the big picture

    How the idea flows

    Input or goalAnonymous Functions…Python result
    Understand the problemApply Anonymous Functions (Lambda)Run the codeCheck the output

    Read the diagram as a simple path: begin with a problem, use the Python idea, then verify the result.

    02

    Everyday connection

    Real-life example

    ↗

    A one-time sorting rule can say which field to compare without naming a full function.

    03

    Learn by doing

    Python code example

    PYTHONExample
    students = [('Ari', 82), ('Mina', 95)]
    students.sort(key=lambda row: row[1])
    print(students[-1][0])
    Expected resultMina
    Try it: Change one value in the code, predict what will happen, then run it and compare your answer.
    04

    Keep this in mind

    Key takeaways

    • A lambda expression creates a small anonymous function, often used as a short key or callback.
    • Think of a real problem where anonymous functions (lambda) could save time or organize information.
    • Test small changes and read the result carefully before moving to a bigger program.

    Quick self-check

    Can you explain it in your own words?

    What is the main idea of Anonymous Functions (Lambda)?

    A lambda expression creates a small anonymous function, often used as a short key or callback.

    Where could you see this idea in everyday life?

    A one-time sorting rule can say which field to compare without naming a full function.

    Keep learning · Hack The Future