Home > AI > Language > Python >

lambda

Eample 1: create a basic lambda

x = lambda a : a + 10
print(x(5))

Example 2:

def myfunc(n):
  return lambda a : a * n

print(myfunc(2)(11))

Example 3: lambda as a parameter

def test(f):
    return f(10, 20)
    
a = test(lambda x, y: x+y)
print(a)

Leave a Reply