 We will specifically focus on counter and DQ container types in Python collections. So let us see what outcome has been planned for this video. The outcome associated with this video is to enable the students after watching this video that they'll be able to use counter and DQ container types in Python. So let us move to hands on and what we'll be using hands on. In the hands on, we'll try to use counter and DQ container types in Python. So I'm going to switch to Google Collab Workspace wherein which is nothing but it's like a Jupyter notebook style service provided by Google wherein we can try Python code snippets. So let us move to Google Collab Workspace. So this is a Google Collab Workspace I have here and let us see one by one what how to use counter and how to use DQ here. We'll see a demonstration of counter and then we'll also see a demonstration of a DQ object. So if you want to use any of these two classes here counter and DQ make sure you import collections. So I'm going to use from collections I'll import counter. So this counter is the one which we'll be using to maintain. So let's call it as Cv as a Cvarr as a counter variable and I'm just initializing a new counter container type. Now if I print what is a Cvarr so that's let us see what exactly it prints. So when I execute it it will just print counter. Now what I'll do is I'll add few variables to it for example it's a let us call it as Cvarr1 and now if I print Cvarr1 I'm trying to just show you the different ways of initializing counter. So Cvarr1 is an counter instance with an empty status. So I'll have one more counter status counter variable I'll call it as Cvarr2 but this time I will initialize with a string ABC and I'll print the Cvarr2 and at the same time I'll take one more counter variable and I'll call it as counter and here I'll provide a list of characters and let me say it's D it's E and it's F and then we'll also print Cvarr3 and okay this was the empty counter and this is empty with a sequence and it almost both are same it's a list specifically defined in form of list syntactic structure. So we'll also have Cvarr4 wherein you can provide direct values so let's say I have A is equal to 2, B is equal to 3 and G is equal to 9 and I'll print the Cvarr4. So now when I execute this you can see the output. So the output of Cvarr1, Cvarr2, 3 and 4 this is blank the output of this line Cvarr1 is blank, Cvarr2 what counter is showing us so it's actually a sequence so what it is telling you that it has tried to maintain a count of IEEE and elements of that IEEE are hashable so it is able to maintain that A occurred once, B occurred once and C occurred once at the same time when you take the output of Cvarr3 so you can see based on same explanation D occurs 1, E occurs once and F occurs 1 and for counter 4 we have specifically defined that A occurs twice and B occurs twice and G occurs 9. So this how we are able to initialize a counter object. Now once we initialize the counter we can even update the counter as well for example here I have A1, B2 and C1 what if I add a one more string called as AABB and CC so I want to add that string and I want to update the count of that. So what we will do is let us move to another segment here so we already have this in Cvarr2 now what I am calling I am calling Cvarr2 dot we are updating that earlier it has a few count now I can directly provide some iterable and here what I am saying AABB, CC. So now if I print the output of this Cvarr2 you should able to see that the count should get updated because earlier it is only once BC all occur once but now I am updating that so now if I enter this you can see that the count has been actually updated here. So update is a method in a counter where it lets me update the count of the what are the sequences at the counter instances maintaining. So these are the various installation of a counter and this is one of the most efficient way to keep track of count of elements. I wanted to show you some functions of collections you can see that this is standard python docs so if you look here you will find that these are the some of the other methods which we have seen a demonstration of the most common other I leave it to you to practice on your own so this is very easily accessible. So this is the counter now what we are looking into this we are looking at the DQ and what you can see that it is a very fast operation and most important thing is this is what the DQ structure is more famous for a memory efficient appends and pops for either side of DQ the approximately almost of one level of performance this is what is very much enticing to the developers to use all this. So generally it has the methods append adds it append left adds to the left and the normal append adds to the right side of the DQ so we had it and one of the very important and little bit tricky one is rotate DQ comes with the built in method to shift elements of DQ either left or right so we will see a demonstration of this so let us take a small example of a DQ so you will be able to understand that so going back so from we will have import it so from collections import deck and then let us say sample deck is equal to DQ and I will provide a list so you have to provide one DQ you have to be constructed from a blank list so even that is also fine it just creates a sample deck element here. So if you print sample element sample deck you should see that it should be just a sample one and if you print length of this it will print the current length of the deck structure okay I think we missed it back here it is zero so now I can add some elements to this for that the call is append so let us first stick to simple integers so I will add element two and then I will print it so you should be able to check the output what happens if I do this okay sorry I misspelled it it is append what is wrong append requires correction okay sorry sorry it has to be this the element of this so you can see that it is now containing two so now if I do this let us say I am adding four and if I print it again what would be the output what would be the output would it be four two or two four four let us take it two four because by default it keeps on adding it to this right if you want to specifically add an element to the left of that you have to call append left you can see that it's four two okay that's what we were talking about append and append so we let's add a few elements to this four and now given the DQ which has six five four let us see a demonstration of rotate so based on the definition with python doc tells if I provide n steps it moves the element to the right and if I n is negative it moves elements to the left so let us call that we call sample deck dot rotate and if I say one can you guess the output so I asked you to shift it to the right default this is right so two goes here so if it's rotate with shift so the element moves it it's not like that it moves goes away and some random element is it it rotates so you can see that DQ being which gives me o of one to pop and left so if you clearly look into this example you should get like whenever you want to implement a specific rotate operations especially if you want to rotate a entire list it would be a very wise decision for a developer to choose DQ because rotate of a elements if it is a DQ structure is a little bit more faster than the standard list implementations why it is because of the o of one push and pop operations so you can think of rotate as one pop from left and push to the right so what do you think is DQ dot rotate faster than a list implementation you can pause the video or you can just watch the video back and try to find out answer for this so the answer for this question that is yes DQ dot rotate is a faster implementation than the list implementation of rotation operations so this is a bibliography your curious reader can always explore these links to find more about the collections the time complexity and what are the arguments which were made in this video so that's it for this video thank you