Nearby lessons
67 of 108Python - Lambda Functions
What Is a Lambda Function?
A lambda function is a small anonymous function written in a single line.
It is often used for short, simple operations.
Syntax
lambda arguments: expressionExamples
s = lambda n: n * n
print(s(4))
add = lambda a, b: a + b
print(add(10, 20))Common Uses
filter()map()reduce()
Why Use Lambda?
Lambda functions help us write concise code when we only need the function once.
Summary
| Term | Meaning |
|---|---|
| Lambda | Anonymous one-line function |
| filter() | Selects items based on a condition |
| map() | Applies a function to each item |
| reduce() | Reduces values into one result |
🧠 Test Your Knowledge
3 QuestionsProgress: 0 / 3
Keep Going!Python - Modules