Right now, it is time to share the functions and the functions, to write a specific commands or specific
instructions, and then you call that function over and over.
You don't need to write and rewrite everything over and over.
So, for example, you add tin to specific then.
OK.
OK, by the way, we already saw functions.
You know, by the way, print is a function, APS is a function, the end is a function with this that
converts the value.
That's the arm that we saw is an esan function.
OK, but these are called built in function.
And what we are going to do is write a customized function.
So I want to add function to add 10 to the value that I but or I.
OK, so how to do that.
Actually before that, let's have a look on the syntax.
The syntax is like this.
You type the name def which means define.
And the name of the function, its name, one one.
OK, open the brackets and inside the brackets we have bar one, bar two.
So these are called parameters.
These are values that can be best when we call this function.
We would have we would have that and we see it now.
I would open the curtain here.
Actually, I think you are getting familiar with Python now because you can see that these are the same
thing that used when we used if condition while before and so on.
OK, we can just open the brackets and put the current here and we need to do to put it inside the indentation.
OK, now we're inside it.
Let's print this is inside one one.
Right, OK.
OK, now also we can have a return value so we can return value return, for example, or right or return
function or return variable that we defined here inside the function.
So if I type or if I declared I equals zero.
And if I return it here, so return.
So this would return unusual.
So this function will print.
This is inside phone one and it will return I, which is the value of zero.
Now, how to call this function actually now just as simple as that, I would name I would put the name
of the function which is fun one.
Right.
But you can see we are required to add part parameters because we have Barwan and Bertka.
But for now, let's do this like that and let's see what will happen.
All right.
By the way, the value return equation.
It will be here, so.
Let's have a look at what will happen.
You can see this is inside one one.
Yeah, but the thing is not here.
Why?
Because we didn't print it out, so I printed it out like this.
Using the brain function, no, if I return here and run it again now, this time not this is inside
one one only, but we have the value of AI, which is zero.
OK, so far so good.
Now let's have another thing.
OK, now what if we have a barometer.
So here.
Bar one and we have bar two, OK?
And this will return I plus bar one plus bar two, OK, so far so good.
Right.
And when I return or I.
The function I need to provide value, so I will provide for the bar one so simple, right.
And 20 for the bar too.
And as you can see, it is integer and integer.
Right now, this is what we will receive and we will get 10 plus 20 plus zero, which means 30.
OK, so let's have a look here and let's run it so you can see it is 30 as expected, right?
Yeah.
By the way, if I print, I hear.
Let's put the brackets.
Yeah, I hear, yeah, let's have a look what happened, actually.
Yeah, you can see that eye is not defined.
Why is that?
Because I is inside the scope or the indentation block of this function only.
So this is a local variable.
But if I define it here.
All right.
Let's have a look here.
So if I define it here, I equal 10 or 11 this time.
Now I value will be 11.
But the precedence when we are inside the front one is go to the local variables, which is the equation.
So here zero blastin plus thirty plus twenty sorry.
Which means the value will be thirty.
But when I receive it here I will not print that one inside the front one.
No I will print it that the one that global.
Global.
OK, let's have a look what we what we will receive now.
This time the first eye is equal 10 or 11.
You can see that this inside one N30, so which means that we didn't do that, actually, if I remove
that and I returned only the value of.
Like this, so this should return zero.
Only.
OK, and actually, let's bring this inside.
You can see that, yeah, I'm pretty sure you are getting the idea, but it's good to have practice
on that.
So I bought one about two suja like this so you can see that I hear would be so the printed one, but
the print right outside the function will be irrelevant because this will use that lovenheim.
OK, you can see that year 11.
This is inside one one and the inside fund one is zero.
OK, which is this one.
The return value would be 30, which is zero blastin plus 20.
The parameters we Besse.
OK.
All right.
So far, so good.
Thanks for watching.