Lambda function or anonymous function
Lambda function or anonymous function What is lambda function? Lambda function is a function they are not declared as other function using def keyword.Rather they are created using lambda keyword. Syntax: lambda argument:Expression Example: sum = lambda x , y :x+y print ( sum ( 7 , 5 )) #in the above code lambda function return the value of sum. #in lambda function x,y:x+y (x,y is agreement and x+y is expression that #get evaluate and return) #it return function object which assign to the identifier sum. lambda function have no name. lambda function can take any number of argument. They are one line argument and hence can not contain multiple line. lambda function can not even access global variable. lambda function with ordinary function def increment ( y ): return ( lambda x :x+ 1 )(y) # in ordinary function return lambda function. #in lambda function x is argument,x+1 is expression #and y is assign argument/passing