Lambda Function in Python

Veröffentlicht am: 30 Juli 2018
auf dem Kanal: Python Marathon
365
9

Descargar el Código: patreon.com/pythonmaraton

Join Patreon: patreon.com/pythonmaraton
^Downloadable code & more! Lambda functions can be used with arrays, if statements and much more. This is a quick tutorial on some of the things you can do with one line lambda functions in Python

This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.

▶️How to Plot Functions:    • Matplotlib Python Tutorial for Beginners  

✅Subscribe:    / @pythonmaraton  

📺Channel:    / @pythonmaraton  

▶️Watch Latest Python Content:    • Python String Slice and List Slice  

▶️Watch Latest Other Content:    • Video  






LAMBDA FUNCTIONS

I’m going to show you a quick easy way to create one line functions in python

These are particularly helpful for computational functions

to create a lambda function type the name of a variable, (we will do f) equals, lambda, a name of another variable (we will do x) colon, then use the second variable to create a function. In this first example we will do x squared

Now to call the function we write the name of it with a value in parenthesis to plug in as x

So 5 squared is 25 and 3.22 squared is 10.368…

In this next example we create a lambda function with an if statement

So our function will be 1 or -1 depending on the value we give it. This has endless applications when coding.

For our last example we will import numpy

This is a three dimensional example. We define the function the same way, only this time when we write the actual function part we treat x as if it is a vector with three values. x[0] is the first entry of the vector

This function will sum the values of our vector, and require that we put a vector of size 3 in

Lambda functions can also be plotted with marplot lib, check the description for a video on how to plot lambda functions

So there you have it, that is how you use lambda functions in python

#PythonMarathon #LearnPython #PythonTutorial


Auf dieser Seite können Sie das Online-Video Lambda Function in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Python Marathon 30 Juli 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 365 Mal angesehen und es wurde von 9 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!