My First Function
Season 02 - Introduction to Python Programming
LAMBDA FUNCTIONS
my_sum = lambda num1=2,num2=3,*args: num1+num2+sum(args)
print(my_sum())
print(my_sum(1, 2, 3))
print(my_sum(5*6))
print(my_sum(5*6,0))
5
6
33
30
Syntax: lambda arguments: expression
No Explicit Return Statements
Limitation : Logic/Control Statement often has to be simple i.e.; one line.
How often used:
- Very Often used especially while performing data manipulation activations. Especially using higher order functions like `map`,`filter` and `reduce`. { Which we will learn in next episode}
- When there are multiple rows while performing data manipulation we can use lambda functions instead of creating explicit functions.