Lambda Function in Python

Published: 30 July 2018
on channel: 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


On this page of the site you can watch the video online Lambda Function in Python with a duration of hours minute second in good quality, which was uploaded by the user Python Marathon 30 July 2018, share the link with friends and acquaintances, this video has already been watched 365 times on youtube and it was liked by 9 viewers. Enjoy your viewing!