Welcome to this lecture.
Dyslexia will be fun lecture because we're going to cover all a lot of thing in this lecture about the
very very scope and packing and unpacking the arguments.
So let's start defining some funds then so I'll saying for funds in and the normal funds and I'll just
create the variable with V is let me say forty five and let's bring this severe value so V is OK.
What am I doing.
So let's formatted first A V is and can simply pass with the format meter and let's say V.
So this is inside the info meter.
So it is calling for it is going to give us the straightforward v value vs forty five.
But again if you see that V value would be okay we value I'll just say V is 56.
Okay.
So vs 56 over here and now I'm just calling the same right here.
So if I said this Daniel C vs forty five and fifty six.
So that means the value of the variable has the local scope inside these funds generally.
So if you see this V is not visible over here.
So if I just remove this V if I said this presale 5 it is going to give us a zero V is not defined because
this is because of this error if I just comment this out the end it is not going to give us any it is
swing that vs 45 because of this statement where we have to get the value of V this V was defined and
say the function but this V is not visible outside of this function.
So if you want to print any value that is V or if I want to say y 89 okay if I want to say again why.
It is also not visible because this way is visible inside these funds and only outside these funds and
this is not visible because this has the local scope inside these funds in and outside these funds and
this is not visible but what if I is a C V is 45 and I'll just omit out this statement now if I said
this and this remove this one to again said this in press five.
They need to source these for to five again because this V which is declared outside of these funds
and has the globally scope.
That means this is visible inside these funds and outside these funds and everywhere.
But if you create any variable any that is toxic that is inside this fund then it has the local scope
it ought to be visible outside that funds.
And this remember that this is the important thing that you need to take here because a whole lot of
error can arise because of this concept that beginners don't understand about this variable is group
that is inside the funds and will be visible inside the funds and only outside that funds and it will
be invisible because it has the local scope not the global scope.
Now let's see about the concept which is packing unpacking the arguments.
First of all to see the bagging the argument let me say this on my console so first of all if I say
something like bring to me okay.
It should be bring me the numbers.
I see three four five if I print this you can see that this is space there is unpacking.
So bringing this statement has something that is a tribute.
I have already shown you in the previous Lexus that if we see something like print me three four five.
We have these ECP in the in the coal mine here.
So he faces CIP which is the separation between each of these numbers would be instead of just this
is space.
I want to add a dollar in between each of these elements that is passing the pin.
You'll see the dollar will be added inside each of this element.
So this is the packing our bicycle on packing.
Let's see some example I'll say number four five six and seven other numbers.
Now let me just print this with unpacking so on pegging of the argument can be done with the single
stroke.
Just remember that and this past year no.
And if I just print this you can see there is unpacking.
If I just bring the number there is no one bagging.
This is simply a list but if you want to unpack you should pass the strike and the variable.
OK.
We have to print this first and we have to pass over here and you could see that David's unpacking of
the number which is not in the case when we just print the list.
So this is done packing.
Where do we just unpack the list.
So now let's see the packing the argument.
So packing the argument will be implemented by the fonts and so let's create the funds and that will
add the multiple number.
So deal now what do we have learned is to add the numbers is the form of a perimeter.
So if I say print a additions a B this is completely valid I'll just call 5 6 0 3 5 if I printed 5 there
5 this is going to give us a number.
If I say it now it 5 this is also going to give us a number.
What if I say I want to add six seven eight six seven again six.
I want to add this number.
So control lists and press five.
It is not going to give us any result because I have already shown you before that it takes to put this
argument but it were given here and this argument was it were given but this it will be gone to the
A D Five will go to the B but we don't have any further parameter which can hold these bunch of numbers.
So if you want to do you can do something like C you can do d You can do.
E F and G and something like that but it is not a practical Louise Willis back this argument so as to
define the new funds and I'll say add in now if you want to pass my people argument you simply put here
a strike and let's call this harks you can call any number or any variable name but I'll simply say
args.
So now what you need to do is simply call the total because we want to add these numbers.
So for i in arcs.
So arcs here is a tuple.
So in the tuple we can just loop.
So this a total and I do it the I and the last return that total for me.
Now you can add multiple numbers so I'll say so.
All bands of these numbers.
So let's save this press for five.
It is not going to give us any result because we haven't printed with you.
So let's print this
save this first specify which is going to give us the results straight away because we have just finished
with pegging our argument.
So all of these numbers here will be converted into a tuple.
So in this tuple we can loop every time it will take a number.
So I will be three.
At first it will land with the total widget 0 plus 3 which will be 3.
Now the total is three.
So in the next loop it will be four four plus three.
It will just add continually all of this and it will just return the total which is just printed over
here.
So this is the concept of backing the argument and looping through it and doing the operation inside
this loop.
So this is the important way to back the arguments and we'll learn the bones of a concept in the upcoming
lectures about the python scene in the next.