Differnce between normal function and lambda function in python

Submitted 3 years, 2 months ago
Ticket #349
Views 293
Language/Framework Python
Priority Medium
Status Closed

Why should we use lambda function ?

Purpose of lambda function and difference between normal function ,lambda function...

Any response will be very great help

Submitted on Feb 11, 21
add a comment

1 Answer

Verified

The primary difference between a lambda and a regular function is that the lambda function evaluates only a single expression and yields a function object. Consequently, we can name the result of the lambda function and use it in our program

In regular function, we have to define a name for the function which returns the result when we call it. A lambda function doesn't contain a return statement because it will have only a single expression which is always returned by default. You don't even have to assign a lambda either as it can be immediately invoked.

Lambda Function Syntax:

lambda x : x + x 

Regular Function Syntax:

​
def (x) :
return x + x 

​

Submitted 3 years, 2 months ago


Latest Blogs