O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

What is Python Lambda Function? Python Tutorial | Edureka

185 visualizações

Publicada em

YouTube Link: https://youtu.be/RQRCWDK9UkA
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Python Lambda' is to educate you about the Lambda functions of Python and help you understand how to use them in various scenarios. Below are the topics covered in this PPT:
What are Python Lambda functions?
Why are they used?
How to write anonymous functions?
Lambda functions within user-defined functions
Using Anonymous functions within
- filter()
- map()
- reduce()
Solving algebric expressions using Lambda

Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in

Publicada em: Tecnologia
  • Seja o primeiro a comentar

  • Seja a primeira pessoa a gostar disto

What is Python Lambda Function? Python Tutorial | Edureka

  1. 1. ❖ What are Python Lambda functions? ❖ Why are they used? ❖ How to write Anonymous functions? ❖ Lambda functions within user defined functions • filter() • map() ❖ Using Anonymous functions within www.edureka.co/python • reduce() ❖Solving Algebraic expressions using Lambda
  2. 2. www.edureka.co/python
  3. 3. www.edureka.co PythonLambda Functionsare: • Anonymousornameless functions • ‘lambda’isnotaname,butitsakeyword www.edureka.co/python
  4. 4. www.edureka.co/python
  5. 5. Also known as throw- away functions as they are needed just once They are also passed as inputs or returned as outputs of other higher-order functions The body of Lambda functions is written in a single line One-time use I/O of other functions Reduce code size Why are they used? www.edureka.co/python
  6. 6. www.edureka.co/python
  7. 7. A Lambda function is created using the lambda operator lambda arguments: expression lambda : “Specify the purpose” lambda a1…n: “Specify use of a1…n“ lambda a1: “Specify use of a1“ SYNTAX: www.edureka.co/python
  8. 8. www.edureka.co/python
  9. 9. Lambda functions are best used within other higher- order functions Anonymous functions within user defined functions def new_func(x): return(lambda y: x+y) t=new_func(3) u=new_func(2) print(t(3)) print(u(3)) www.edureka.co/python
  10. 10. www.edureka.co/python
  11. 11. filter() Used to filter the given iterables(lists, sets, etc) with the help of another function passed as an argument to test all the elements to be true or false. my_list = [2,3,4,5,6,7,8] new_list = list(filter(lambda a: (a/3 == 2), my_list)) print(new_list) www.edureka.co/python
  12. 12. map(): Applies a given function to all the iterables and returns a new list. my_list = [2,3,4,5,6,7,8] new_list = list(map(lambda a: (a/3 != 2), li)) print(new_list) www.edureka.co/python
  13. 13. reduce(): Applies some other function to a list of elements that are passed as a parameter to it and finally returns a single value. from functools import reduce reduce(lambda a,b: a+b, [23,21,45,98]) www.edureka.co/python
  14. 14. www.edureka.co/python
  15. 15. Copyright © 2017, edureka and/or its affiliates. All rights reserved. www.edureka.co
  16. 16. www.edureka.co/python