Lambda Function (PYTHON)
# SYNTAX.
# lambda arguments : expression
# Addition using LAMBDA function.
x = lambda a : a + 10
print(x(5))
#The expression is
executed and output is returned.
# Subtraction using Lambda function
y= lambda b:b-20
print(y(30))
# Multiplication using
LAMBDA function.
x = lambda a : a * 10
print(x(4))
# Division using
LAMBDA function.
x = lambda a : a / 10
print(x(5))
# More than one
argument.
x = lambda a, b, c : a + b + c
print(x(5, 6, 2))
# Lambda function with
another function.
# Function that doubles the value.
def myfunc(n):
return lambda a : a * n
mydoubler = myfunc(2)
print(mydoubler(11))
# Similarly we can change the values passed and
get different results.
Comments