LambdaFunctionsLambdaFunctions.LambdaFun

SharanyaRajaram 14 views 8 slides Aug 23, 2024
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

LambdaFunctions.pptx


Slide Content

Lambda functions

Lambda functions Similar to user defined functions , but without a name Called as Anonymous functions Efficient for simple expressions , ie for expressions with single line of statement. Useful when functions are used once.

Define lambda functions lamdba – keyword for defining anonymous functions argument(s) – variable to hold the value to be passed into the function, can have multiple values depending on the need. Expression – code to be executed in the lambda function. Anonymous function – does not have a return keyword , as it automatically returns the result of the expression, once executed. Donot use lambda functions for complex structures like if else , loops, define user defined functions for the complex structure.

Functions - example

Lambda function Invoke a lambda function immediately

Iterables Anything that consists of series of values like, characters, numbers etc. In python it is String, lists ,   ranges, tuples, and so on. Lambda is used with two other functions 1. filter 2. map 

Filter Focus on a specific value in an iterable .

Ex:
Tags