Lambda Function,map(),filter()
Lambda Functions A lambda function has the following syntax. Syntax of Lambda Function lambda arguments: expression Lambda functions can have any number of arguments but only one expression. The expression is evaluated and returned. Lambda functions can be used wherever function objects are required. Example of Lambda Function Here is an example of lambda function that doubles the input value. # Program to show the use of lambda functions double = lambda x: x * 2 # Output: 10 print(double(5)) In the above program, lambda x: x * 2 is the lambda function. Here x is the argument and x * 2 is the expression that gets evaluated and returned. This function has no name. It returns a function object which is assigned to the identifier double. We can now call it as a normal function. The statement double = lambda x: x * 2 is nearly the same as def double(x): return x * 2 Use of Lambda Function We use lambda functions when we ...