Hello, in this session, we would be discussing about apples to apples, immutable in nature, so we
can consider apples just like list, but with the properties of immutability.
Now, when we talk about immutable, immutable means that the element of that particular data structure,
which is dapple here in this case, cannot be modified so that others can have new people object, such
as list.
So the elements of the couple could be mutable in nature, but the element cannot be modified as such.
These Stupples elements cannot be changed, but it's multiple elements can be changed, so let us see
how this entire thing works.
In case of couples, we can define couples in this particular format, giving people list inside this,
or we can provide the object separated by comma inside bases, which would create a new double for us.
Now, another thing which we could do is we can just give the couple's name and the account, which
would provide us the number of elements present in that, and with the index, we can add value to a
particular topic.
So let us see how this entire thing works.
So let us first create a topic, so let that happen in the city and we wanted to have several elements,
so let us say.
I want to have this number.
And I want to have a springboard to present Philip.
And one of the number, the intimate, so this is my double.
Now I can go into my company using fake.
So here you can see this couple has been created.
I can check the type of.
So it is a topic now we can create a couple with another method.
Here we are simply giving the values common, separated.
We can also give the values, comma, separated inside of basis.
So this is just the same thing, but only additional bases have been provided here.
Apart from this, I can create another couple by having a couple inside this, so when we can do is
let's say I want to create a you and inside this stuff, I want to have that ability and I want to have
another double which got these values.
Three, four.
Obama seventy eight.
And let me bring to you.
So here I have unestablished, which has supples inside this.
Now, let's try to see the properties of immutability in case that happened, so when we say immutability,
it means that the elements of the couple can not be replaced.
So let us stay if we want to have value.
See you.
And I want to create a new value inside this city.
I want to take the index value, let's say I want to check the index, see why.
And I just done this.
So you can see I get the value of the index one in.
Now, let's I want to add another value to this topic, I want to add value in the index to.
So.
Let's see if the value exists or not, so it does not exist, double indexes out of range.
Now, let us try to add a simple number inside this, which is immutable in nature, so that if an object
does not support assignment, which means that once the tuple has been created, I cannot really add
another element to this.
Let us see another thing, let us try to modify the element which is already existing, so let us try
to replace some element in the self.
So let us check the value in the.
Three, let let's see what is value in these three.
Well, the value in these three now let me try to put another value in and save fifty for.
And you can see that the double object does not support the assignment, so I cannot assign the value
for people to the third element in the double.
Now, let us bring to you again here is that apathy?
Now, let us try to do one thing.
Let us try a few things.
See this string.
Let us see if the string value can be replaced with that.
No value cannot be replaced, but legacy for string value can be replaced.
Now.
This is index zero one two.
And in the inside this I want to I want to pull the string itself so it is not a very huge.
Change, which I want to bring in inside instead of Halo, I just want to put in high and this is again,
not supporting.
So you can see the property of the couple is that the values are present inside this, if any index
cannot really be replaced.
Now, let us give this to you inside this new couple.
We have a value.
Thirty four, former seventy eight.
So let me try to replace that.
So let me try to modify this on inside you one, I want to go to another value saying I want to go with
you.
So this is, again, not supportive.
Now let us try to do another modification, so let us try to modify this value.
So first we try to retrieve this particular value.
So let us see you and inside this view, I want to get the first one with the terrific almost seven
eight and I want to get the zero one insight this just thirty four.
And I want to assign a value to to it.
So this again is not possible because this is again.
Now let us try on a third, let us try on the radiation.
So let us create a double the one and now this time this stuff.
We have values like one, two.
Then let me put a list in it.
One, two, three, four, five.
And now let me put.
And at the in.
Hello, and let me put.
Another couple in it, so we have already seen the example of what happened inside this.
But still, let's try this again, so in this one, this is the one for me now in this one, let us
say I want to modify this element, which is a list.
So let us retrieve this was 41 and inside the one.
I want to get the second index.
Which is the list itself.
Now, let me try to modify this by assigning another list instead of this one.
So let me put in one, two, three, four, giving the series also the same.
And let me try this, so this is, again, not supported, so this means that no matter what element
is present in adopting, that element cannot be replaced either.
It is a no.
It is us doing.
It is a list.
It is adopted.
That element cannot be replaced.
So once you have created a couple, the element of that that cannot be replaced, no new element can
be added element.
Would we be OK?
Now, one more thing to understand here is this is a very important property of the.
Which is, although I cannot replace the elements of this, I cannot modify this one to any other value,
to any other value, but what I can do is because one is immutable in nature, I cannot modify the value
of what I cannot modify the value of.
I cannot modify the value of string.
I cannot modify the value of it because these are immutable items.
That list is in itself usable image, which means that I can modify a simple list.
So let's see if I create a list, say.
Any X, Y, Z list, which has some value, one, two, three, this value of this list can be modified.
But if I had a couple that I modified so I can either create like another string, although I can create
a new string, I can create a new number, but I cannot create a new couple.
I cannot completely change that up a little.
So what we do here is.
I can modify this list, this list, so let us try it on the lady, so in the one which is next door.
Let me try to get the value of the second index.
So this value is three.
Now, let's see if we can actually change this volume.
OK, so let me bring it to you one.
So this is my original D1.
And out of this one.
What I want to do is I can change, I want to change this value tree or let's say I want to change this
value.
Hi to hello.
So that would be.
Three.
And I want this value to begin with, hello, and let me die of this and let me be one again so you
can see that although I cannot change the values of the couple itself, but if the element of the couple
is mutable in nature, which is I believe it is a list or it is a dictionary or it is a sect, I can
modify the value inside that list, dictionary or step.
But if it is a string, a number or another couple, I cannot modify those values.
So this is the only property which you need to remember about the carpet, which would be sufficient
for you to be walking in future.