We're going to see what the python functions.
So let me tell you an example, suppose you have a hundred lines of code to calculate, uh, the area
of something and you want to repeat it four or five times.
So you cannot copy paste those 100 lines of code five times to calculate some value.
So what you're going to do is you are going to write a function.
It will do the calculations for you and it will return some result to you.
So if you want to call it 10 times, you don't need to copy those hundreds of code.
And we can just simply call this function 10 times and you'll get 10 values.
So this is very simple.
So let's get started.
So now let's say function need to define the function.
So we need to use the def.
So define the function.
Let's calculate to work on the area.
So this is my function.
I want to do so.
I want to put the, uh, open brackets and I need to parse some arguments.
So generally, what will be the arguments are to the area of a rectangle.
Right.
So I can say a flawed.
And and throat beat, so I can like this and I concert a colon and then the interrogation goes on and
you need to write some code that will calculate the lantern to breath so that the area is equal to allow
in to be.
So this is a sample code I'm going to tell you of because there are so many advanced calculations you
can do.
But this is just for practical example.
So I can use this function and I can pass some values of the length and breadth to calculate this area.
So now I want to see is equal to.
Gary, great area.
Off I want to sell and interpret for you.
Come on, sir.
Well, it's obvious seven come off right now.
This call will executer and this area will be in dysfunctionally.
So this area is called local, where local will work to this Takrit area.
If you access this area outside of this function, the U.S. area, because this local variable and it
will be only defined only into this function.
So to access this one, you need to return the value in a certain area.
So what this means is whenever you are doing the Callcredit area, R7 come off and this function will
be called and elsewhere, you can determine and be very contentious and it will be corrected and it
will return.
So the return value will be stored in the seat, so you can think like this is a seat is equal to area
area, which represents this variable, the variable value.
And let me comment on this one and let me run the program.
All right.
I'm sorry, I just to find, like other programming languages, sorry, you don't need to define fraud
or any you can just say cover the and the values will be automatically restored dynamically as integer
or the string or whatever you pass.
So you do not get any output because by default, functions cannot get executed until they are called.
So calling the function without mentioning the function somewhere in the code.
So this is the function template and this should be top of the calling code.
So my code is calling here and the function should be, uh, before this one because the interpreter
starts from top to bottom.
And if this line is, uh, here, then it gives you an error.
So that's why we need to define functions first.
And so we are not going to call this function.
Let's execute this one.
So we do not print anything, let's print where we have seat.
So we got to testify.
So we called the function and it has calculated the value, suppose if you want to define some function
and you do not want to assign any value or you want to leave that for the future properties, then want
to increase its function.
And then you can pass, so this daughter pursues this path to reserve some area of space for this function,
for the future of this.
So if you want to set up that so you can start working on this subject whenever the time comes out in
the future, if you want to update any function, you can just put the past.
And if you remove this pass, you'll get the error because there should not be an empty function.
So as you can see, demolition expert.
So this one is in transition.
It is something that you should not be like empty function, you need to put the viewer on this.
Now, the program exudes character.
So you can also also bring something.
So now I'm going to call this function.
Since this function is not returning anywhere values, I just need to start anything I can just simply
call this function on this.
And you can see the output has been blah, blah, blah.
It has been from this function.
So that's all the basic concepts about the function.
We are going to view only the basic concepts.
There are also some intermediate concepts like verbal and arguments, but it's really more for discourse
and just not work.
Functions are fine for us.