Indecision, we are discussing Biton Dictionary.
So what is a Python dictionary and how do define that one?
What are the different methods we can play on this Python dictionary?
We'll be discussing that point into details.
In Python Dictionary is an unordered collection of items, while other compound data types have only
value as an element.
Addiction has a key value pair, so that is a very important one.
So we had a discussion on leads.
We had a discussion on top of that.
We had a discussion on set that is saw that we are having multiple different elements.
Are there?
They may be or may not be of the same or different data types.
But here we are finding this dictionary is quite different from those those data types because he didn't
get a dictionary.
Well, having the key value pair dictionaries are optimized to return values when the key is not.
So if we know the key, if we pass the key as argument, we can retrieve the respective value against
the key which has been stored restored onto the dictionary object.
So here you have considered one.
Is a my dict one.
So this is a variable.
We're just containing one colon grade.
So what is one that is a key.
What is a value.
That is a raid is red is a string.
Yes.
So it should be enclosed within signal codes.
And here this key value pierde must be separated by this kolon.
Then come up so that we are having the second member and having the third member and so on.
And each and every member is nothing but key value pair.
So we are having this my deck too.
So here we are having this name treated.
So there is a one member here.
So comma H Colon 35.
Address Colon Calcutta.
In this way that things have got represented.
So here you are having the different mythos, which you can carry out on the community.
So the first one is a clear remove all items from the dictionary.
Copy.
Return is hand a copy of the dictionary, then form keys.
So sequins within third bucket were putting this come up.
Be so written, a new dictionary with keys from the sequence and the Ballew equal Dupee default to none
here.
So in this way you are also having the get key within the third and we're having B here.
So return the value of key.
If the key does not exist a exit then written D.
And default is to none.
So in this way we are getting this one.
So let's consider this one as exist.
So now this is my items.
So written in new view of the dictionaries items.
That is a key and value.
So these are the different methods that there and the respective descriptions were given.
You can go to them because actually you are having a plan to show you all these methods, which are
very much usable in our in our python programming, in our life demonstration.
So let us go for the demo session for the better understanding that how this method can be used on our
dictionary objects and what other reasons we're getting.
So here is a demonstration for you.
Biton Disunity is an unordered collection of items.
And while other compounder types have only the value as an element.
But in guessable dictionary, we'll be having our key polu peer and dictionaries are optimized to the
two values.
When the key is known to us.
So let us go for one creation of a of a dictionary here.
So new dict is equal to one kolon.
Hello.
So here one is the key and Hallowes the value.
And you see Colan is the respective separator between the Key and Peele.
So this Key and Peele appears to be separated by this comma and the whole thing must be included within,
Culebra says, as if it is a set in upset.
Also, we had all the same set elements are to be interested in culebras this, but here it gets upset.
We only have the element zikr members there.
But here in the case of dictionary, we'll be having a key value pair.
So print new deck.
So now let go for the execution.
You can find that by just printing this.
This particular dictionary and then print Newdegate.
So this outcome has come.
Print new dict one.
So we are given.
One means a key.
Hello.
So here we are having this key.
So the respective value will be held.
So Hellam has got printed.
If you go for this get.
And if you give two, then two is the key here.
And the value will be high.
So high has got printed.
So now it might be asking me what is the difference between this new DECT one and new dict up, get
two here.
The difference is that if you keep some if you keep some illegal or say non existent key here.
So 10 is not there at present.
So if I go on execution, then I can find that key error is coming.
So here is the key, the value part of what we are giving it.
The respective key is not existent here.
We are getting one error.
That is a key error.
So key error can.
So that is that issue.
But in this case, if I put one in pallette key here.
So here you can find that it is returning none.
It is returning none.
So that is a basic difference between these two respective statements.
That is print new one.
And print new dict dark.
Get.
So if we give what Dukkha says the valid key in that case, I'm getting this Halloween high as a explained
operating value.
So for the new dict one I'm putting here.
So now you see for this one.
For this against this key.
The value has got updated from hello to here.
So now we are having this adding value.
So that is a new dict for is the normal state.
Now here you can find that here this fall is not existing here.
So a new respective keep her loopier will be inserted in this dictionary.
Now creating a new dictionary.
So, Nick, let me go for the execution.
So print squares, the respective values are getting printed.
So now remove a particular item.
So we are going for squares, dot, pop four.
So as of key is given radically for.
So that means for column sixteen.
This particular this give a loopier will be deleted.
And that's why you it is returning the value at first.
So 16.
And you can find that, that for column sixteen that give her loopier is missing now.
Remove an arbitrary item.
We can go for this pop item.
So in this case, a pop item, one arbitrary item will be deleted.
So here you can find that five comma twenty five.
It has got delegate.
So the respective key value Peate is not is now not existing.
Delete a particular item.
We can go for this deal and then square one.
So this particular Keever loopier will be deleted.
So we are remaining with this two column four and three Kolon nine here.
Here we have defined.
One new dictionary.
There's a square.
So squares have got printed.
Now we are going for these squares are clear.
So it removes all the all the key value pairs.
So remove all the items.
And now if we print this square, it is printing the empty dictionary.
So delete the dictionary itself.
In that case, if in that case we'll be going for dayle squares.
But after that, if you want to print squares as the squares have got deleted.
So it would produce one error.
That is a name error.
So there is a name attached.
So name squares is not defined because we have used this deal here.
So the full declaration of the dictionary itself will get deleted.
Next one, creating a new dictionary, using comprehension so you can find that X in range six, that
means X will be ranging from zero to five because six will be exclusive.
So zero.
One, two, three, four, five.
So these are the six values for X.
So we are creating a dictionary that is X, Kolon X will be the key and the value will be X, star X.
So now in this case, if I print the squares, I'm getting the zero zero squared.
And then one one squared and then two is the key and the value will be two square.
Three is the key.
The value will be three square.
In this way, up to five kolon.
Twenty five.
So we are getting this.
So dictionary membership test.
So how to do the membership test here.
So here in this case, we discuss only the dictionary using comprehension.
Now it is a I here will be going for the testing of the membership.
So one dictionary has got defined.
So the name of the dictionary is squares.
So now one in squared.
So one diski is present.
So one in squares will be giving us.
True, because we are testing the membership of this one as a key in this dictionary.
Do not in square.
You see, the two is not there.
So two not in square will produce the outcome.
True here.
But print at 49.
In squares 49 as a key is not present here.
So that's why it is returning the value.
It is returning the boolean value.
That is a false.
So here what do we are passing by dividing.
You were mentioning Bellwether.
They are the key that Akif we're not considering this 49, which is present as a value as a key 49,
is absent.
So putting 49 in squares, it is returning the value falls.
Now we are going for this iterating through a dictionary.
So squares one Kolon one three nine five 125 25.
Define this one so far.
I in squares.
So print squares, eyes.
So you can go for the execution.
You can find that you are printing this one nine, 25, 49.
So they are all the values.
So here this I has been treated as a key, so respected value has been popped out and that has been
retrieved and they have what printed in this iteration.
So we are finding out that there is a there is a squared is one dictionary here.
We're going for the Lynn.
So these are the Inbal functions in a dictionary.
So Lynn will print the length of the dictionary.
That means a number of key value pairs.
So here you are printing this one as five because one, two, three, four, five.
Keep a loopier, Sadir.
Print Shattuck's squares.
So you can find that the respective P values, they have become shotted.
They have become shorted here.
So in this way, we're having some inbuilt methods that are inbuilt functions, that there are building
functions, that there is nobody Kenly that can be applied on the dictionary objects.
So in this discussion, we have a detailed discussion that how to create this dictionary and what are
the department permitted and not permitted operations that we can carry out on a dictionary?
I think now the conception is getting clear to you.
Thanks for watching this video.