Biton topples, so under the chapter, Python detectives who are going to define another new day today.
That is known as the python topples.
So what does a python topples?
In case a python topples, we go.
We are going to define one couple, but the double elements will be enclosed within fast brackets and
dapple elements can be having into heterogeneous data types.
So you might be asking me what is the difference between DAPPLE and at least that list is mutable.
But dapple elements are immutable.
That is, they cannot be updated.
So there is a basic difference between a double and a list.
The list will be enclosed within third brackets.
That is a square.
Brackets and doubles will be enclosed within our first brackets.
So let us go for the what are the different differences and features of doubles?
We're going to discuss here.
So in many aspects, the table is similar to a list.
But the basic difference between the two is that we cannot change the elements of a table.
That is a table is immutable once it is assigned.
Whereas in a list, the elements can be changed.
That means the list is mutable.
Advantages of double over list.
So falling at the certain advantages of implementing it, topple over a list and below list are the
some of the main advantages.
So what are the advantages?
Why should they?
Why should I learn dapple here.
So we generally use toppled for heterogeneous different data types and for list it is generally for
the list will hold the homogeneous data.
But obviously lists can also hold that heterogeneous Jackett elements.
But actually in general, we use list to hold homogeneous data type data.
So since staples are immutable and iterating through a couple is faster than with the list.
So that is a slight performance boost.
So as this double is immutable, so iterating through the toppled members will be a little bit faster.
So we are getting some boosting of the performances so doubles that content, immutable elements can
be used to as a key for the dictionary with list.
It is not possible because we know that in a dictionary the key values will be all is unique in nature.
So that's why as it gets up double as it is immutable as a data, items cannot be changed.
The members of the tables cannot be changed.
So that's why cannot be updated.
So tables that contain immutable elements can be used as a key.
For one dictionary, if you have data that does not change.
Implementing it as dapple will guarantee that it will remain as in the read only mode.
So there are different building functions with the help of as you can.
We can do some processing of them, members of the tunnels.
So forsworn is the all written through.
If all elements of the couple are true, any return true.
If any one of the elements of the temple is true, you do want it written and you might object.
It contains the index and the value of all the items of the couple as pairs.
Next one is the Lin Redonda.
Linda, there is a number of items in the double.
Next one is the max return the lock.
Largest item in the double.
Next one is the main one, the function itself.
We are getting the part.
What is the purpose of the function?
So return the smallest item in that double.
Next one is the short.
It takes elements and the couple returns a new short list.
And next one is some return.
The sum of all elements in the table.
Next one is a couple converts.
Then you dribble list.
It might be the string, might be the set.
Might be additionally in to a double.
So here we're having the type conversions.
So now let us go for one demonstration for the better, understanding how we can use and define and
operate with about double objects in python programming.
A double is very much similar to a list.
The difference between the two is that we cannot change the elements of a couple.
Once it is assigned, whereas in the list the elements can be tensed.
That means list is mutable and dapple is imitable.
Now the difference here is that in Kessab least we shall inclosed about elements using tarde records
opening and closing.
But it goes up double will be enclosing them.
It was in the past decade opening and the fussbudget closing.
So that is another difference where jobs are being hit.
So now let us discuss what are the advantages of dapple over, at least since double's have quite similar
to list.
So both of them can be used in similar situations as well.
And however, there are certain advantages of implementing it.
Dapple over the list.
So we can consider the force advantage as that we can generally use stapel for heterogeneous, different
data types.
At least for homogeneous, that is of the similar data types.
But in the previous video also we have shown you that list can take multiple different data type data.
But it is a common practice that wherever, wherever we'll be using our variables of the different data
types to be meant to be put in one structure.
Then in that in that case, we'll be using the table.
But in case up a list will be going for the homogeneous data types.
Since doubles are immutable, so iterating through the couple will be fostered out to some extent compared
to that of the list.
So here we are getting some slight performance boosting.
So topples can contain immutable items, elements and can be used as a key for our dictionary.
So as a couple elements are immutable so it can contain the dictionary keys and just not possible Ingersol
list as it is mutable.
And if we have our data, which you do not want to change anymore.
So we should implement it using dapple because in that dapple will be where we'll be keeping our data
in a right protected format.
So here we are having one couple.
We are created and that is at a empty table.
So double one.
So it is empty table if we print.
We are getting the output like this.
So now we are having this double.
We got Brint initialize with this dapple do with some integer data will be there.
Elements will be there in the couple.
So it has got printed like this.
Here you are having the heterogeneous one is that it may be the implied it, maybe that is.
But remember my name is emplace salary at a department in which he or she is working.
So that is our department is there.
So in this case, if we print the couple three, we are getting the outcome like this.
Now, creation of mystic couples now will be going for the creation of mystic couples.
You can find that this is up, but it is a string.
But this is a list and it is another couple here.
So one list has become the element of the couple and another couple, maybe the element of another couple.
So Pynt couple for if you go on printing, we're getting the output like this.
So we know that lists will be included within square brackets and couples will be enclosed within POS
bracket.
So that's why it is a couple.
And it is a list.
So double can create can be created without any penalties.
So now you can write this one, you can find that that couples were going to wear create here.
We haven't enclosed them within the past decades, but the couple has got created and it has got printed.
Dapple unpacking is also possible.
You know, that goes up double fi.
We're having one, two, three for such a date items.
So now we are going to assign them to imply I.D., imply name and price, implied salary and imply department
so we can go on printing them.
I'm getting this employee I.D. implied name implies salary and also the implied department for that
type of the stapel fight will be a class couple.
So in this way we can have our list are a couple as the members of another couple.
Now we are going to access our table elements.
So how to do that one you see here where defining one table with this welcome characters and then print
will couple one.
We're getting this outcome like this.
So now table one one.
So this is my index value.
So we know that index will be starting from zero.
So index one is this one.
So it is having the value eat.
So if I print that one, I'm getting it here.
Similarly for here for table one three.
So zero one two threes or C will get printed.
And here you are printing this five.
So zero.
One, two, three, four, five.
So AIM has got printed here.
So now in that next case, we're having this nice nest.
Couple two, we're having this point.
And this is one Leavesden.
And another couple is there.
So if you go on printing this nest double to getting it printed now from the zero element, you are
picking up the third character.
So from the zero 10 amendments, the Gillette index means this one.
And from the third ketamine's, we're having this one P at Zaret Place.
So this index is one.
This index is to this index is three.
So any will be printed.
And it has got printed accordingly.
And for the next doubled to one two.
So that means we are considering this item number one.
Index number one is there.
And then to do means that this particular one is at index zero.
This two three is that index one and four is at index two here.
So that's why Ford has got printed here.
So Ford has got printed.
Next one is our next one is about double two to two.
So that means we are considering the second element and the second data.
So what is the value here?
So value is nine here.
So here the well is nine.
So I'm getting here nine.
So in this way, you can access elements from a couple here.
So let's go for the next example.
Now slicing double contents.
So it was well defined.
One couple which is containing all the characters of the string.
Welcome.
So here we are going for the slicing.
So index number one, two, three.
So one kolon three means.
One, two, three.
But three will be is exclusive.
That dominating index.
That is up to which the index we are mentioning that is stopping index will be all is exclusive.
So here you can pick up the characters on the index one and two three.
Index one is E an index two is L.
So accordingly, the values will be picked up.
So here to see we haven't mentioned the starting index, but the ending index will be minus three.
So this is my minus one, minus two, minus three.
So this one minus three.
So what did happen?
So always remember the ending index dominating index is all is exclusive.
So it will print all the members from index number zero two up to see here.
So that's why we are having this one as w e l see.
So they have what printed.
Now, from starting with the index number three, I Abin mentioned any dominating index here.
So index number three means zero.
One, two, three.
So from here it will print up to the last element.
So that's why the outcome has come like this.
Here to see where we haven't mentioned any kind of starting and stopping index values.
So that's why the full couple will get printed here.
So that is about double one.
So print double one one, Kolon three will produce output like this.
Then Kolon minus three will produce output.
This one because we're are not mentioning the starting index.
So to start from the very start.
And they need to proceed up to minus four.
So this is my minus one, minus two minus C and up to minus four.
This W, E, l, c will get printed and it has got printed.
Similarly, I've explained the other cases.
Now we are going for this double elements which are immutable.
So as it is of that, after creating this particular couple.
So if we print that Apple, it will produce output like this.
But if we go on updating its content.
If you go on operating its content.
So it will produce a one error message.
You can find that there is a typewriter.
So a couple object does not support item assignment.
So that's why it is producing one error.
And the name of the error is typewritten here.
OK, so now Dapple can be reassigned.
But you can assign a nude tuple to this same double one variable.
So you are having this print double one.
So this stapel one object has got initialized with the new double.
So that is not causing any problem.
But I am a bit is not there is not allowed because it is it is about immutable.
So that's why if we go on printing now you see the new dapple has got assigned to the double one object.
Next one is a concatenation of the couples, so here to see where printing this double do and double
three.
So now we are going for this concatenation using plus.
So is it double one content and then double two content.
They have got concatenated in the same table.
So now here to see where having this particular couple and this double will.
I'm just multiplying it by four.
That means four times.
This again will be there.
This particular string again will be there and that will produce one double.
So there is a syntax of writing.
Deletion operation on a couple.
So here we're having one couple here.
So if you go for delete, dapple, do, then obviously it'll produce some either operation.
Why?
Because you know that that couple is immutable.
So now what will happen if they uncheck this one?
If I go on unchecked.
So the error will be Opt-In is type error and that is double object does not support item deletion.
So that is the message is getting printed.
So that's why I'm putting this one under comment here.
So but we can delete the end.
So Dell double four, so that full, full or whole double fold will get eliminated, will get deleted.
So in the in that case, if you print this stapel for it to print the Nimir and name double fold is
not defined in the message.
So now we are having some double mehtar, so we're having some double mentors.
So double five.
We're having this respective all the characters of welcome and double five that count E..
So to count that, how many times?
This is awkward in here.
So I'm getting this one as two because E has got two times in this double in the couple members.
So now it is going for the index C so it will find out the occurrence, the index of the C character.
So this particular C string that.
So that's why you are getting this through here, because it is index zero, index one index to an index
three.
So now let me check if you have this C for another place, if we have the C for another place, then
what will happen if we go on executing?
I'm getting three back again because you will just check the first occurrence of this as string C in
this particular couple here.
So double operations.
So here we are having this double six.
You can find it so double sixes there.
So now we can go for the print once.
So these a couple six see in double six seas there.
So that's why it is giving me the outcome to see.
Not in double six outcome will be false in double six.
That is.
No, it is here.
So it did return false.
It not in double six.
It will return true here.
So it is checking the state membership.
Next one is a tradition through couple elements.
So here you have defined one couple here where you find one couple.
And if you go on using this for loop, that is four letters in double six.
We are printing this letters.
We're getting that for each and every iteration.
But just picking up one element from this couple members.
And it has got assigned to this letters.
And later, later letters is getting printed.
So now building functions with the couples.
So what do you find?
One toppled.
A couple has got printed, Max, of the couple's seven.
So maximum element from the Staples or seventy seven has got printed minimum of couples seven.
So here you'll will be having the value event then short at double seven.
So they'll be remaining in the sharded form.
The return one is in the Thomas list.
You can find that they are enclosed within square brackets.
Our list of Couples seven will give me that count of the elements in the couple available.
So in this way, we have discussed that.
What are the different operations?
What are the different functions that they are inbuilt functions are there with the help which we can
operate on a double and also the difference between the list and a couple we have discussed in decision.
Thanks for watching this video.