Posts

Showing posts with the label Lambda Function

Python3 Lambda Function

Python    Lambda Function  Anonymous/Lambda Function :    In Python, anonymous function is a function that is defined without a name.      While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambda keyword.     Lambda functions are used extensively along with built-in functions like filter(),map(),reduce() . Syntax:                    lambda arguments: expression Example        double=lambda x: x*2        print(double(5)) output : 10        def double(x):              return x*2        print(double(5)) output: 10         #example using filter() function        lst=[1,2,3,4,5]        even_lst=list(filter(lambda x: (x%2==0),lst))        prin...