Posts

Showing posts with the label Anonymous/Lambda Functions

Python Tutorial 23 --- "Anonymous/Lambda Functions"

 Python Tutorial 23 --- Anonymous/Lambda Functions In Python DOC As we have studied function in the previous lecture, we know that if a program has a large piece of code that is required to be executed repeatedly, then it will be better to implement that piece of code as a function. Functions improve code reusability, modularity, and integrity. In this tutorial, we will see how to declare Anonymous functions and how to return values from them. As we have studied in the previous lecture, the syntax for function declaration is as follows: def function_name ( ) : Copy What is Anonymous function? In Python programming, an  anonymous function  or  lambda  expression is a  function definition  that is not bound to an identifier (def). The anonymous function is an inline function. The anonymous functions are created using a lambda operator and cannot contain multiple expressions. The following example will show how anonymous functions work:  result = ...