kopia lustrzana https://github.com/animator/learn-python
Update Lambda_Function
rodzic
fe735c00b5
commit
cc82210e0b
|
@ -1,5 +1,6 @@
|
|||
## Introduction
|
||||
A Lambda function in Python is a small, anonymous function defined using the `lambda` keyword. Unlike regular functions defined using the `def` keyword, Lambda functions can have any number of arguments but only one expression. The expression is evaluated and returned. Lambda functions are often used for short, simple operations and are commonly utilized as arguments to higher-order functions like `map()`, `filter()`, and `sorted()`.
|
||||
A Lambda function in Python is a small, anonymous function defined using the `lambda` keyword. Unlike regular functions defined using the `def` keyword, Lambda functions can have any number of arguments but only one expression.
|
||||
The expression is evaluated and returned. Lambda functions are often used for short, simple operations and are commonly utilized as arguments to higher-order functions like `map()`, `filter()`, and `sorted()`.
|
||||
This helps you to write concise code.
|
||||
## Syntax
|
||||
|
||||
|
@ -16,7 +17,8 @@ print(x(2))
|
|||
4
|
||||
```
|
||||
## When to use lambda functions
|
||||
Lambda functions are best suited for situations where you need a small, simple function for a short period and are not going to reuse it elsewhere. Lambda functions are commonly used as arguments for higher-order functions such as map(), filter(), sorted(), and reduce(). They provide a concise way to define simple functions inline.
|
||||
Lambda functions are best suited for situations where you need a small, simple function for a short period and are not going to reuse it elsewhere. Lambda functions are commonly used as arguments for higher-order functions such as map(), filter(), sorted(), and reduce().
|
||||
They provide a concise way to define simple functions inline.
|
||||
## Difference between Def function and lambda function
|
||||
The def function is useful for taking multiple expressions, it is used for writing multiple lines of code. We can use comments and function descriptions for easy readability.
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue