SlideShare a Scribd company logo
Lambda
Lambda is a keyword in Python used to define functions, more specifically
Anonymous Functions, and such functions are known as Lambda Functions or
Lambda Expressions.
• The expression n ** 2 gets evaluated first, and a value gets returned to the identifier square. The
identifier square can now act as a function, and thus we can pass any number as an argument to find
the square of a number.
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
Keep in mind that the map can take any iterable as an argument and not only a list.
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
• Summary
• Lambda
• Function with many arguments but only one expression.
• It helps to make our code pythonic and to create function wrappers.
• Map
• A function that applies a given function to each item of an iterable and
returns an iterator.
• It provides a faster way to transform an iterable based on the given condition.
• It can have multiple iterables.
• Filter
• It has the same syntax as the map function.
• It helps in extracting items from an iterable based on the given condition.
• Decorators
• A decorator is a design pattern in Python that allows a user to
add new functionality to an existing object without modifying its
structure. Decorators are usually called before the definition of
a function you want to decorate.
• Functions in Python are first class citizens. This means that
they support operations such as being passed as an argument,
returned from a function, modified, and assigned to a variable.
This is a fundamental concept to understand before we delve
into creating Python decorators.
• Before we learn about decorators, we need to understand a few
important concepts related to Python functions. Also,
remember that everything in Python is an object, even functions
are objects.
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
Here, we have created two functions:
•ordinary() that prints "I am ordinary"
•make_pretty() that takes a function as its argument and has a nested function named inner(), and returns
the inner function.
We are calling the ordinary() function normally, so we get the output "I am ordinary".
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
Here, the ordinary() function is decorated with the make_pretty() decorator using the @make_pretty syntax, which is
equivalent to calling ordinary = make_pretty(ordinary).
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
Generators
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
advancedfunctionalprogramming(lamba).pptx
Ad

More Related Content

Similar to advancedfunctionalprogramming(lamba).pptx (20)

_Python_ Functions _and_ Libraries_.pptx
_Python_ Functions _and_ Libraries_.pptx_Python_ Functions _and_ Libraries_.pptx
_Python_ Functions _and_ Libraries_.pptx
yaramahsoob
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
prabhat kumar
 
Decorators.pptx
Decorators.pptxDecorators.pptx
Decorators.pptx
KeerthanaM738437
 
Advance python
Advance pythonAdvance python
Advance python
pulkit agrawal
 
Functions_new.pptx
Functions_new.pptxFunctions_new.pptx
Functions_new.pptx
Yagna15
 
Chapter 2 Python Functions
Chapter 2               Python FunctionsChapter 2               Python Functions
Chapter 2 Python Functions
11210208
 
Learn more about the concepts Functions of Python
Learn more about the concepts Functions of PythonLearn more about the concepts Functions of Python
Learn more about the concepts Functions of Python
PrathamKandari
 
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
prasadmutkule1
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
SudhanshiBakre1
 
lambda engineering students machine learnings.pptx
lambda engineering students machine learnings.pptxlambda engineering students machine learnings.pptx
lambda engineering students machine learnings.pptx
mrsam3062
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
Daddy84
 
Functions and modular programming.pptx
Functions and modular programming.pptxFunctions and modular programming.pptx
Functions and modular programming.pptx
zueZ3
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
Manav Prasad
 
CH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptxCH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptx
sangeeta borde
 
functions.pptx
functions.pptxfunctions.pptx
functions.pptx
KavithaChekuri3
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Kamal Acharya
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
vinay chauhan
 
Python. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdfPython. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdf
prasenjitghosh1998
 
CPP06 - Functions
CPP06 - FunctionsCPP06 - Functions
CPP06 - Functions
Michael Heron
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
Prerna Sharma
 
_Python_ Functions _and_ Libraries_.pptx
_Python_ Functions _and_ Libraries_.pptx_Python_ Functions _and_ Libraries_.pptx
_Python_ Functions _and_ Libraries_.pptx
yaramahsoob
 
Functions_new.pptx
Functions_new.pptxFunctions_new.pptx
Functions_new.pptx
Yagna15
 
Chapter 2 Python Functions
Chapter 2               Python FunctionsChapter 2               Python Functions
Chapter 2 Python Functions
11210208
 
Learn more about the concepts Functions of Python
Learn more about the concepts Functions of PythonLearn more about the concepts Functions of Python
Learn more about the concepts Functions of Python
PrathamKandari
 
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
ESIT135 Problem Solving Using Python Notes of Unit-2 and Unit-3
prasadmutkule1
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
SudhanshiBakre1
 
lambda engineering students machine learnings.pptx
lambda engineering students machine learnings.pptxlambda engineering students machine learnings.pptx
lambda engineering students machine learnings.pptx
mrsam3062
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
Daddy84
 
Functions and modular programming.pptx
Functions and modular programming.pptxFunctions and modular programming.pptx
Functions and modular programming.pptx
zueZ3
 
CH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptxCH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptx
sangeeta borde
 
Python. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdfPython. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdf
prasenjitghosh1998
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
Prerna Sharma
 

Recently uploaded (20)

Software Development Business Plan1.pptx
Software Development Business Plan1.pptxSoftware Development Business Plan1.pptx
Software Development Business Plan1.pptx
vkprintingsolution
 
Career Planning After Class XII: Your Roadmap to Success
Career Planning After Class XII: Your Roadmap to SuccessCareer Planning After Class XII: Your Roadmap to Success
Career Planning After Class XII: Your Roadmap to Success
Dr. Radhika Sharma
 
CHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptxCHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptx
72200337
 
material-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptxmaterial-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptx
JyotirmayNirankari
 
Introduction on Speaking skills Power Point
Introduction on Speaking skills Power PointIntroduction on Speaking skills Power Point
Introduction on Speaking skills Power Point
helenswarna
 
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
shenleighmaemolina
 
When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?
SnapJob
 
Bronchitis_Presentation_with_Images.pptx
Bronchitis_Presentation_with_Images.pptxBronchitis_Presentation_with_Images.pptx
Bronchitis_Presentation_with_Images.pptx
monmohanchowdhury8
 
Huckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptxHuckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptx
study2022bsc
 
Placement cell of college - why choose me
Placement cell of college - why choose mePlacement cell of college - why choose me
Placement cell of college - why choose me
mmanvi024
 
Top Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality EducationTop Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality Education
top10privatecolleges
 
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDHSEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
123candemet2003
 
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptxSHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
ArshjotSingh30
 
RCM-billing in medical coding0000 1.pptx
RCM-billing in medical coding0000 1.pptxRCM-billing in medical coding0000 1.pptx
RCM-billing in medical coding0000 1.pptx
liajohn0808
 
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.pptTraditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
XolaniRadebe7
 
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdfLCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
rafaelsago2015
 
Sample animal revalidation protocol for resaecrh based.pptx
Sample animal revalidation protocol for resaecrh based.pptxSample animal revalidation protocol for resaecrh based.pptx
Sample animal revalidation protocol for resaecrh based.pptx
azeemccras
 
Employment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptxEmployment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptx
JunaidAlvi5
 
English For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication SkillsEnglish For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication Skills
ankitbeherabiru
 
sorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).pptsorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).ppt
IndalSatnami
 
Software Development Business Plan1.pptx
Software Development Business Plan1.pptxSoftware Development Business Plan1.pptx
Software Development Business Plan1.pptx
vkprintingsolution
 
Career Planning After Class XII: Your Roadmap to Success
Career Planning After Class XII: Your Roadmap to SuccessCareer Planning After Class XII: Your Roadmap to Success
Career Planning After Class XII: Your Roadmap to Success
Dr. Radhika Sharma
 
CHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptxCHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptx
72200337
 
material-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptxmaterial-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptx
JyotirmayNirankari
 
Introduction on Speaking skills Power Point
Introduction on Speaking skills Power PointIntroduction on Speaking skills Power Point
Introduction on Speaking skills Power Point
helenswarna
 
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
shenleighmaemolina
 
When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?
SnapJob
 
Bronchitis_Presentation_with_Images.pptx
Bronchitis_Presentation_with_Images.pptxBronchitis_Presentation_with_Images.pptx
Bronchitis_Presentation_with_Images.pptx
monmohanchowdhury8
 
Huckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptxHuckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptx
study2022bsc
 
Placement cell of college - why choose me
Placement cell of college - why choose mePlacement cell of college - why choose me
Placement cell of college - why choose me
mmanvi024
 
Top Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality EducationTop Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality Education
top10privatecolleges
 
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDHSEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
123candemet2003
 
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptxSHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
ArshjotSingh30
 
RCM-billing in medical coding0000 1.pptx
RCM-billing in medical coding0000 1.pptxRCM-billing in medical coding0000 1.pptx
RCM-billing in medical coding0000 1.pptx
liajohn0808
 
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.pptTraditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
XolaniRadebe7
 
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdfLCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
rafaelsago2015
 
Sample animal revalidation protocol for resaecrh based.pptx
Sample animal revalidation protocol for resaecrh based.pptxSample animal revalidation protocol for resaecrh based.pptx
Sample animal revalidation protocol for resaecrh based.pptx
azeemccras
 
Employment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptxEmployment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptx
JunaidAlvi5
 
English For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication SkillsEnglish For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication Skills
ankitbeherabiru
 
sorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).pptsorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).ppt
IndalSatnami
 
Ad

advancedfunctionalprogramming(lamba).pptx

  • 1. Lambda Lambda is a keyword in Python used to define functions, more specifically Anonymous Functions, and such functions are known as Lambda Functions or Lambda Expressions.
  • 2. • The expression n ** 2 gets evaluated first, and a value gets returned to the identifier square. The identifier square can now act as a function, and thus we can pass any number as an argument to find the square of a number.
  • 5. Keep in mind that the map can take any iterable as an argument and not only a list.
  • 8. • Summary • Lambda • Function with many arguments but only one expression. • It helps to make our code pythonic and to create function wrappers. • Map • A function that applies a given function to each item of an iterable and returns an iterator. • It provides a faster way to transform an iterable based on the given condition. • It can have multiple iterables. • Filter • It has the same syntax as the map function. • It helps in extracting items from an iterable based on the given condition.
  • 9. • Decorators • A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. Decorators are usually called before the definition of a function you want to decorate. • Functions in Python are first class citizens. This means that they support operations such as being passed as an argument, returned from a function, modified, and assigned to a variable. This is a fundamental concept to understand before we delve into creating Python decorators. • Before we learn about decorators, we need to understand a few important concepts related to Python functions. Also, remember that everything in Python is an object, even functions are objects.
  • 13. Here, we have created two functions: •ordinary() that prints "I am ordinary" •make_pretty() that takes a function as its argument and has a nested function named inner(), and returns the inner function. We are calling the ordinary() function normally, so we get the output "I am ordinary".
  • 16. Here, the ordinary() function is decorated with the make_pretty() decorator using the @make_pretty syntax, which is equivalent to calling ordinary = make_pretty(ordinary).