Hello YouTube, I'm Parways and this is our 13 video in Python tree programming B6
In the previous video we have learned how you can create functions or methods in Python tree
In this video we are going to talk about creating Lambda functions in Python 3
so I have created a new Python file and before writing our code let me explain
about Lambda functions a lambda function in Python programming language is a small
anonymous function so in Python anonymous function is the function that is defined
without a name while in normal if you have watched my previous video let me show
and normal we when we create our functions in Python we can write diff and we can
we write our function or method name but in lambda function and instead of
writing diff we write lambda so let me show you the syntax of a lambda function
the syntax you can write like this we have a lambda after that we rewrite our arguments so and after arguments we write our expression so this is the syntax of a lambda function or a lambda expression now let me show an
example for example I'm going to create a lambda function lambda and the
argument is a and a plus five so now I want to print X
5 now if I run this you can see that I have received 10 let me make some more
example and it will be you'll be familiar with lambda functions let me create a
lambda function that multiply argument a with argument B and print the result so
I want to create like this lambda function that to multiply argument
argument A with argument B and also print result for me okay now X lambda the
argument we need two arguments argument A and argument B and expression that we
need to multiply these two arguments so a times B okay now in here let me print
my Lambda function and I want to add my five and for example I want to multiply this let me run it you can see that now I have received 20
okay now now I'm going to create another example I'm going to create a lambda function that sam's argument A B and C and print this result so I have three arguments
and I want to sum those arguments and print themselves so let me create a lambda
so lambda I have three arguments a B and C and I want to sum these arguments and after
that I want to print my lambda function so for five for example two now if I run it
okay now you can see I have received 11 now this was lambda function but the power of
lambda is better shown when we use an anonymous function inside another function
so let me show you for example I have a function let me call it my function
and the parameter with parameter in now I want to to return lambda you can see that I have an anonymous lambda function inside a function or a metal so a I want to multiply this with my n parameter not no n okay now after this let me
print this let me first create my
funk and my function and I want to three in this example when I add a number for
example 11 now it will double my this number so you can see I have received 33
and if I give it for example 2 and it will give me sex and if I make it
5 it will give me 15 if I change this to 5 it will give me 25 it will give me
25 so now you can see this was a lambda anonymous function inside a function
so thank you guys if you have any question please let me know and for
the further videos don't forget subscription of my channel