Welcome to this lecture.
This lecture will be all about the natives.
So we have learned about the list now and now it's time to see more complex that is stuck to us which
is a dysentery so it is important lecture of the Python programming.
So first of all if you see that this native it is quite similar to that that this native English Dictionary
which we used to look up for the words and we get the meaning.
So there is a key which is basically your words and there is a meaning which is your values.
So this is the combination of key and values and we make use of this key in value to create the dysentery
to assess the dysentery.
So just remember that.
So this is the main reason we call this as a dysentery.
So this native is a honour's collection of items so what that that means is in the case of a list it
is ordered.
So if I make any dishonesty and if you want to assess the element it want to be ordered it will be unordered
and we'll see about that in the next minute.
But for now this remember it is quite similar to the list but it is on order and it has the key and
value pier.
So next thing is that we just combine the element in the form of a key and valuable Liddy said this.
And now let's see how to create the dignity and how to do some manipulations in the dictionary.
So first of all we have to give name to the native so I'll say my dict is my dignity.
And to create the dictionary if you remember to create the list it was square bracket for now.
It is this native so it should be curly braces.
So if you read into and if it does see the matrix then it is aimed to the snake if you stick that type
of these my dict if you want to do this then you could see these glasses that this native type.
So the next thing is to just import some of the characters to this native so let's make our this native.
So first of all I've said there is a key and you give the colon and there is value.
So this is the way to create the dignity.
So next one is also the key value so you can enter any number of key valuable here.
So key would be something let me say one and the first let me say is Ahrens.
So the first value is weddings.
And the second let me say it is Apple.
Now if this print is semantic then it is your DNA the complete DNA is been thus created over here.
So you can also do something like okay let me make this native with a multiple mixed keys.
So if we see we have now key as a string and let me say John which is also the String key and value
both is a string.
But for now I have to this clear the mixed key value pair.
That means I'll just insert some of the list over here.
So this is a completely valid until unless you open with the college braces and close it.
It is going to be your DNA.
So just remember that we can make any data type of way here is a key and the value it can be listed
can be its string it can be integer.
It can be boolean anything.
So this is completely valid.
If I print this my dick then you can see that is it is this native.
So we can do this completely so next way is to create the my dignity with the method which is inbuilt
method dicta method.
So if I do this and in the dictum method you have to pass in the forms of a mapping mapping is in the
form of your tuple.
So let's see how can we make this so as say one will be able and this apple is a string so that means
you have to put in the court and let's close this one and the next one next element will be also in
the tuple.
So this is the tuple and if I just screw this one close first your list and close your dict method then
we have now just created my dignity so you can see this that same dignity that we just created with
this curly braces.
Now it is created with this dict emitter.
So this is the way to create your dignity.
So let's see how we can assess now this dignity.
So first of all.
So let me just make a simple dignity and I'll just make with this scarlet braces.
It is easier to do so I'll say my name is my first key and I'll say John is the name and next to be
is is is integer.
So I'll say 23 days.
Now let's see how can this get the element which is drawn from this DNA.
If you want to do that then first of all you just take that name of the DNA and put your This is square
bracket that normally we do in the case of a list and in the case of string do if you want to use this
element from the list.
And from this string we make use of these square brackets and that is same for the case of ordinary.
So if you want the element from the DNA that it is not true the indexing technique.
So if you just remember in the case of a list we used to assess the element from the index we used to
normally pass a zero here to get the first element 1 to get the second element.
But in the case of dignity we have to keep the keys.
So if you want the values this give the key in saleable here if you want to AIDS this would give the
keys away.
So if I hit enter you will get 23 if you want the name that is done then you have to pass the key is
a name and you are going to get the john.
So this is the way to get over the next way you can also do is something that is get a method of the
DNA so you can now give the A's over here and closure get method you are going to get 23 over here.
So get is also the one way to assist the element of the DNA so you can do this way or you can do just
by passing these key value here are basically keys to this get the values out from the DNA.
So let's see now how can we change or add element to this dishonesty.
So first of all let's see how we can update the values.
So what if I want to change this is from 23 to 27.
First of all you have to assess that element and that is done by this way.
And now you have to assess the A's and indices.
I want to assign something like twenty seven values then if it's a spring.
Now my index then you are going to see that is has been changed from twenty three to twenty seven.
So this is the way to this is is the element that sends the element of your dignity if you want the
addition of the item which is completely new.
Then you can do something like add address to this dishonesty and things eight to maybe you continuum.
Now if you just see this DNA you can see the address has been added It's in the pile over here in this
DNA.
So this is the way two things are to add element to your dignity.
So let's see now how we can just remove this dignity or basically how we can just change the element
of this dignity.
So first of all let me just copy this and let me just clear all of this.
So now
let me create the same scenario by here and OK.
If I just sit into here this native is created.
So if I see the dysentery then diseases dysentery.
So let's see some of the operations we can do on this dysentery so first of all let's see how we can
just pop out the element from this dysentery.
So first of all you have to this get that dignity.
And after that you'll see the method that is saying pop pop mentally same is that list.
Now if you want to pop up the element you have to pass the keys to it.
So what do you want to have to pop is.
Basically I want pop dates and if you do this and it is going to give us 27.
Now if you just see the dignity then 27 out.
Basically this whole key value pier was been removed from this pop method.
Now we have chains our DNA so we can do this or you can simply do something like Pop Idol methods and
that does the same as before.
So this is the way to this delete or assist item.
You can also source on the Google for the inbuilt method of the dysentery.
So these are the common the matter to see that is a pop out to assess them how to delete them and basically
how to this ISIS the element of the dictionary will see much more advanced programming the upcoming
lectures about the list comprehension subject oriented programming and that will be the rap for this.
See in the next one.