We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Lambda Function
In Python &Introduction:
A Lambda Function in Python programming is an
anonymous function or a function having no name.
It is a small and restricted function having no more
than one line.
Just like a normal function, a Lambda function can have
multiple arguments with one expression.
If you have a single expression to be executed, then the
lambda function is extremely useful as compared to the
traditional function defined using the def keyword.Syntax:
Here’s the syntax of Lambda Function in python.
lambda argument(s) : expression
There can be a number of arguments but only one
expression.
The lambda function comes in very handy when
working with the map, filter, and reduce functions in
Python.Examples:
~—o\
Comparison between
lambda function and
regular function syntax.
result = SE ted
(multiply_by_2(5))
(result(5))
Python program to find a+b whole square using
lambda.
ECS
(eenUsing lambda with filter, map
and reduce fucntions:
cacao
tre
print(1i
filter_answer = filter(lambda x : x<5, input_list)
print (list(filter_answer))
sr Se
Pee ees Sere Mee ce aeeri 3)
ett ee)Thank you!
Did you find
this post helpful?
Follow us for more
related content and
projects.
Like this post and share it
with your friends.