Download our e-book of Introduction To Python
Sulochana Kamshetty
3 years ago
X= 1
Y = 2
>>> lambda x, y: x + y
3
Add 20 to
argument a, and return the result:
x = lambda a : a + 20
print(x(7))
17
x = lambda a, b : a * b
print(x(4,6))
24
x
= lambda x,y,z
: x+y+z
print(x(5, 6, 2))
13
(lambda x, y: x + y)(2, 3)
5
h = lambda x: x*x*x
print(h(7))
343
def myfunc(n):
return lambda a : a * n
r = lambda x, y: x * y
r(12, 3) # call
the lambda function
36