1multiply = lambda x,y: x * y
2multiply(21, 2) #42
3#_____________
4def myfunc(n):
5 return lambda a : a * n
6
7mydoubler = myfunc(2)
8print(mydoubler(11)) #22
1nums = [1, 2, 3, 4, 5]
2
3
4print(list(map(lambda n:n*n, nums)))
5#lambda n : n in this case is the passed value
1Lamda is just one line anonymous function
2Useful when writing function inside function
3it can take multiple arguments but computes only one expression
4
5Syntax:
6 x = lambda arguments : expression