Python Lambda | |||
| |||
A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Syntax
The expression is executed and the result is returned:
Lambda functions can take any number of arguments:
Summarize argument a, b, and c and return the result:
Why Use Lambda Functions? The power of lambda is better shown when you use them as an anonymous function inside another function. Say you have a function definition that takes one argument, and that argument will be multiplied with an unknown number:
Use that function definition to make a function that always doubles the number you send in:
Or, use the same function definition to make a function that always triples the number you send in:
Or, use the same function definition to make both functions, in the same program:
Below YouTube content is also helpful for better understanding Tags: Python Python Lambda | |||
| |||
| |||
Login for comment |
SIMILAR POSTS Python Arrays |
OTHER POSTS IN THE SAME CATEGORY Mastering Excel Data Manipulation with Python |