Lambda functions Similar to user defined functions , but without a name Called as Anonymous functions Efficient for simple expressions , ie for expressions with single line of statement. Useful when functions are used once.
Define lambda functions lamdba – keyword for defining anonymous functions argument(s) – variable to hold the value to be passed into the function, can have multiple values depending on the need. Expression – code to be executed in the lambda function. Anonymous function – does not have a return keyword , as it automatically returns the result of the expression, once executed. Donot use lambda functions for complex structures like if else , loops, define user defined functions for the complex structure.
Functions - example
Lambda function Invoke a lambda function immediately
Iterables Anything that consists of series of values like, characters, numbers etc. In python it is String, lists , ranges, tuples, and so on. Lambda is used with two other functions 1. filter 2. map