Have a look at this code:
# Python code to illustrate cube of a number 
# showing difference between def() and lambda(). 
def cube(y): 
return y*y*y; 
g = lambda x: x*x*x 
print(g(7)) 
Formatted
print(cube(5)) 
output:
343
125
Without using Lambda: Here, both of them returns the cube of a given number. But, while using def, we needed to define a function with a name cube and needed to pass a value to it. After execution, we also needed to return the result from where the function was called using the return keyword.
Using Lambda: Lambda definition does not include a “return” statement, it always contains an expression which is returned. We can also put a lambda definition anywhere a function is expected, and we don’t have to assign it to a variable at all. This is the simplicity of lambda functions.