Coming to the list of variables and the use references now variables to list differently, then they
store other values of variable, will contain a reference to the list rather than the list itself.
A reference is just a value that points to some bit of data, and the list of reference is a value that
points to the list.
So this results in slightly different behavior of your code.
Now that you know, what are the variable store strings and integer values, we would enter certain
commands in the interactive shell and check the output.
For example, we'll go back here and let us try to type this pan equals two forty two.
For example, say cheese equal to the value of spane.
Let's give spinn equals two hundred and let's try to put in the value of spane.
Oh sorry we made a mistake.
Spinous forty two cheese equal to span span equal two hundred.
And now let's print so we get the value hundred.
Now let's try to put in the value of cheese a still forty two.
So we have assigned forty two to the first span variable and then we copy that value of the span and
assign it to the variable cheese.
So then we later change the value and spend two hundred on new number.
Doesn't affect the value in the cheese variable because Piñon choose a totally different variables that
store different values.
But list doesn't work this way.
When we assign a list to a variable, we are actually assigning a list reference to the variable.
So if we try to make certain code that makes the distinction easier to understand.
For example, we try to make the list one that's equal to we give here certain values in the list.
OK, one, two, seven, for example.
And then we create C red one that's equal to forgive list one.
Then we try to make where one at the index one.
We try to give there some text C that's right down by ten for example.
And now let's try to print the value of list one you see in list one.
Also it has changed and if we try to print the value through variable, even where one has changed,
so this code might look old to you, the chord changes or change, not only the variable that is very
one, but both were one and the list one values also.
So when we create a list, we assign a reference to it in the variable.
But in the next line we have copied only the list of difference in the variable that is variable or
list one to variable, not the list value.
This means that the value stored in the list one and let one now both refer to the same list.
So there is only one underlying list because the actual list was never actually copied.
So then we modify the first element of the word one variable.
We're actually modifying the same list that list one refers to.
Let us understand another concept that is passing references.
No references are particularly important for understanding how arguments are passed to the functions
or methods.
When a function is called the argument, values are copied to the parameter values and for list this
means a copy of a reference is used for the parameter.
Now, to see the consequences of this action, we will create a new file and we would enter certain
code into it and then try to execute it.
So let us go back here and see a new file.
We will define a particular matter.
See dummy one.
In this we are giving parameter one and in this particular matter we are seeing parameter one up and
see Biton as a text.
After this we come back here, we create a list, one that's equal to say, one, two, three.
Some values are given.
Then we call that the method that is number one.
And we pass this list one as the parameter to it, and then we try to print the value of the list.
Now, let us save this as C demo fifteen thought B vi.
That's E drive HACKENBUSH and let us try to run this.
So we are getting one, two, three and plus one more value is appended to it.
So then you run the particular course.
We have noticed that the metadata Skold return value isn't used to assign a new value to the variable
that we have created.
Instead, a list is modified directly.
So when we ran the program, we get the value as one, two, three come up bitin, even though we are
having two different variables.
One is if we look at our program, one is our list one and one is the parameter that this parameter,
one that contains separate references, they both refer to the same list.
Now, this is why the append Biton matter called inside the function of the list, even after the function
call has a record.
So keep this behavior in mind.
Forgetting that Biton handles list, variables this way can lead to some confusing box succumbing to
using the copy poppy to duplicate a particular list value.
Now, if you want to copy a list value, you can import the copy module to call the copy deep copy function,
which returns a separate copy of the list.
It is that that has been basically passed to it.
For example, if we go for the let's close this domino and let's go back here and we try to create C
over that's equal to zero comma.
One, two, three, four, five, six, seven.
Now we say import copy.
Then we say another variable similar to that's equal to the US copy, not the copy, and we pass the
VAT as the variable.
Then we see the word to add the index of one.
We want their python to be printed.
And now we print the value of where we get zero one, two, three, four, five, six, seven.
But now if we were to, we get it.
Well, we have editors that zero one.
Then we have Biton three, four, five, six, seven.
Now because they copied our deep copy function, was used to copy the list in the variable that is there
to where to when an item in two is changed, the original way is unaffected.
We would be using this later in some sections.
When we come back to some simple substitution ciphers.
That's it from the station.
Thank you very much.