WEBVTT

00:00.940 --> 00:06.580
Hello, everyone, in this session, we will discuss about functions, so first of all, let us see

00:06.580 --> 00:08.760
what is the need of creating a functioning.

00:09.220 --> 00:14.940
So let us look at this particular piece of food that I have created, a list of numbers.

00:16.000 --> 00:18.700
The list contains numbers from one to seven.

00:19.930 --> 00:29.860
I have created a variable which has value, and I'm iterating on double this number list, which will

00:29.860 --> 00:32.230
retrieve one number at the time.

00:32.800 --> 00:42.040
And then I'm adding the number to the desired so that I get the value as a sum of the entire number

00:42.040 --> 00:42.400
list.

00:42.850 --> 00:47.860
So let us print the result, which is intermediate.

01:03.160 --> 01:05.350
Let us see the intermediate results until.

01:07.410 --> 01:14.820
So here you can see the number is additionally zero, it added the value one to it, then it added the

01:14.820 --> 01:20.160
value to three and four so that it adds all the values together.

01:20.160 --> 01:22.910
And finally you get twenty eight as a result.

01:23.220 --> 01:28.020
So we are getting a some of the value of a set of numbers here.

01:28.710 --> 01:34.980
Now this is just one scenario, so let us think what will happen if you want to do the same addition

01:34.990 --> 01:40.320
operation several times so would be writing this entire piece of food.

01:40.650 --> 01:47.220
Again and again that is not really feasible and that would not be even more feasible when we have a

01:47.220 --> 01:51.520
very long piece of wood, which you want to use again and again.

01:51.870 --> 01:55.410
So in this particular situation, we will be using functions.

01:55.740 --> 01:59.770
These functions will help us to run a particular piece of food.

01:59.790 --> 02:02.280
Again and again without the right thing, it.

02:10.530 --> 02:18.870
So let us see what the functions of function is, an independent and reuseable block of food, which

02:19.080 --> 02:23.840
you can call any number of things from any place in the program.

02:24.450 --> 02:30.200
So I need not read this particular piece of food just when I want to live.

02:30.240 --> 02:32.840
I can create it whenever I want.

02:33.090 --> 02:37.780
It can be present anywhere in the program and I can call it whenever I want to eat.

02:38.460 --> 02:44.190
It is an essential tool for programmers to split a big project into smaller modules.

02:44.430 --> 02:46.400
Now, how is it also useful?

02:46.710 --> 02:54.120
That is, if I want to use this particular code again and again and I want to store it somewhere so

02:54.120 --> 02:58.120
that it is more simpler to see, then I can use a function.

02:58.140 --> 03:01.280
So let's see how a function would be created out of this.

03:01.620 --> 03:05.460
So to create a function, we can get this entire Diaco.

03:06.590 --> 03:14.120
So to begin with the function, we will need the definition giver, which is this, this means that

03:14.120 --> 03:16.530
we are starting to define a particular function.

03:17.030 --> 03:18.970
Then we give a function name.

03:19.130 --> 03:21.990
So let's say we want to create a function for adding.

03:22.010 --> 03:23.940
So we are seeing naming it either.

03:25.120 --> 03:31.570
After that, in the round bracket, we need to give the argument which will be given to it the input

03:31.590 --> 03:38.160
parameters, so this entire function will work on the no list, which will mean we will be providing.

03:38.440 --> 03:41.480
So we will mean no list.

03:41.740 --> 03:48.040
You can name it anything other than the colon, which would mean that the definition of the function

03:48.040 --> 03:50.940
is starting now.

03:50.950 --> 03:53.740
We will give the indentation without indentation.

03:53.740 --> 04:01.850
It will not understand that the food which we are about right now is a part of this entire function.

04:02.080 --> 04:03.670
So let us start writing the code.

04:03.970 --> 04:08.840
So in this particular piece of code, we will need the number list again, but we already have it.

04:08.860 --> 04:13.140
So we don't really need it now because it has already been defined.

04:13.510 --> 04:18.760
Now, each time the function will run, we would have to meet the value of the desired.

04:19.420 --> 04:23.440
So that is the reason why we will put it equal to zero here.

04:26.510 --> 04:29.450
Then we will need the entire I don't.

04:34.910 --> 04:37.560
So this is the entire piece of code now.

04:37.600 --> 04:43.890
We don't really want to bring in the media results because we want this to walk silently.

04:43.910 --> 04:47.560
I'm just giving them to us so we will not bring that here.

04:48.360 --> 04:53.140
Now, these intermediate results, we will not be printing now.

04:53.150 --> 04:59.720
It will again be invented because this result is a part of this Falu.

05:00.890 --> 05:03.260
And the sprint is the final sprint.

05:05.090 --> 05:12.710
Now, if you want to run this, so for this post, we will shift and this means that that function has

05:12.710 --> 05:13.470
been defined.

05:13.830 --> 05:20.240
Now the definition has been completed, the function has been created, but we have not really called

05:20.240 --> 05:23.970
the function now without calling the function, it will not run.

05:24.320 --> 05:25.960
So, two, done this function.

05:25.980 --> 05:27.370
We will have to foil it.

05:27.620 --> 05:29.330
So we will see this.

05:30.560 --> 05:35.840
I we will give the no list again, so we will see novelist.

05:38.030 --> 05:47.870
Now, if the shift into this will run the Diaby support, which was a part of this definition and give

05:47.870 --> 05:52.640
us the desired, because we have already asked it to frame the desire for expanding the desire for us

05:52.880 --> 05:55.520
now if we don't ask it to bring the desired.

05:59.430 --> 06:05.700
So we will have done this again once we did this and then when we done this, it will not give any result,

06:05.700 --> 06:07.860
although it has completed running.

06:08.520 --> 06:14.910
Now let us say we don't really want to predict the result, but we want to use it for some other.

06:16.990 --> 06:23.250
So what we can do is instead of pretending that we can simply resume the research,

06:26.260 --> 06:33.220
so when we see the dome, that is once this function would run, it will return a particular value to

06:33.220 --> 06:33.510
us.

06:33.790 --> 06:34.750
So let us see.

06:35.560 --> 06:36.640
Let us run this.

06:36.940 --> 06:45.190
Now, what we can do is we can either print that is out that we can, which we get from the Idaho.

06:46.330 --> 06:51.730
So here we can do this or we can simply take this into a variable.

06:54.810 --> 07:02.390
And we can use it later, such as the last five, and we just want to print.

07:08.260 --> 07:10.460
And let us bring virosome.

07:15.850 --> 07:21.540
So here you can see we can use the value statically after returning it from the desert.

07:22.480 --> 07:28.570
Now the name which we have given in the definition need not really be the exact name which we will be

07:28.570 --> 07:34.300
using here, the name which will be coming to the function so it can have any value.

07:34.420 --> 07:36.070
So let's say it is an.

07:37.190 --> 07:40.950
OK, so when we see those in, it will still walk the same way.

07:40.970 --> 07:42.620
It doesn't make any difference.

07:48.130 --> 07:57.430
Now, let us see another thing, let us try to create another function which will add multiple input

07:57.430 --> 07:58.010
values.

07:58.270 --> 08:00.280
So let us define another function.

08:01.690 --> 08:04.450
Let us call it either do I'm in this.

08:04.450 --> 08:11.300
We are taking numbers I g so we are taking two numbers and I enjoy.

08:12.130 --> 08:15.370
Now, if you can say that here, we are not giving any particular data.

08:15.670 --> 08:23.500
So this means that it can take any time and it will automatically understand the data to be whatever

08:23.500 --> 08:24.490
we are providing.

08:25.150 --> 08:27.810
Now we see a dissolve is equal to zero.

08:28.300 --> 08:35.800
Now instead of dissolved equal to zero, we can simply not give a definition to result because we will

08:35.800 --> 08:39.970
be anyhow adding these two numbers and we can see a desired.

08:41.630 --> 08:43.040
Is equal to.

08:46.300 --> 08:49.900
We will have to give just a single indentation result is equal to.

08:51.100 --> 08:55.670
I love you and we concentrated on you.

08:57.120 --> 09:03.330
Now, I want to call it, I will say I do and I will, given the numbers here.

09:08.140 --> 09:09.460
And when I ran this.

09:12.050 --> 09:15.320
It will return the some of these values.

09:16.340 --> 09:20.480
Now, another thing, what I can do is instead of writing it this way.

09:24.420 --> 09:30.840
I can return this directly so I don't have to create a new variable result for this.

09:36.260 --> 09:37.850
And it will we'll just see.

09:39.480 --> 09:47.370
So this is about functions now, using the same time I'm using similar process, you can create a much

09:47.370 --> 09:50.910
complex function and use it in your project.

09:52.480 --> 09:53.080
Thank you.
