What is lambda?



A lambda function is a one line anonymous function that you don't plan on reusing. It can take any number of arguments, but can only have one expression.

Syntax
lambda arguments : expression

Examples
1. A lambda function that adds 10 to the number passed in as an argument, and print the result. x = lambda a : a + 10 print(x(5)) 2. Multiplies argument a with argument b. x = lambda a, b : a * b print(x(5, 6)) 3. Using lambda with the map function to square a list of numbers. numbers = [4, 3, 6, 9, 11] squared = list(map(lambda x: x**2, numbers)) print(squared) [16, 9, 36, 81, 121]
 * 1) Returns: