WEBVTT

00:03.270 --> 00:10.980
In this session, we will discuss about dictionaries dictionary is an unordered collection of key value

00:10.980 --> 00:13.590
pairs with unique piece.

00:14.830 --> 00:20.650
These are unique within a dictionary, while the values may defeat.

00:21.710 --> 00:31.220
The values of a dictionary can be of any data, while the keys must be awful, immutable data such as

00:31.220 --> 00:33.700
string numbers or doubles.

00:34.850 --> 00:37.730
Let us see how we can create a dictionary.

00:48.880 --> 00:53.770
Let us start by creating a dictionary so we can create a dictionary.

00:54.830 --> 00:58.010
By simply giving you the name, say.

01:00.350 --> 01:00.950
They one.

01:04.140 --> 01:12.900
And to create a dictionary, we need the holy places inside the holy places, we will provide the key

01:12.900 --> 01:15.770
value pairs separated by a comma.

01:16.560 --> 01:23.950
So we will give the first key, which could occur key can have values like strength numbers or double.

01:23.980 --> 01:26.700
So let us play the string.

01:28.020 --> 01:29.040
Same name.

01:31.300 --> 01:32.750
And the value.

01:33.750 --> 01:36.480
Will be, let us say, Munsie.

01:37.800 --> 01:41.130
We separated, we see each.

01:45.120 --> 01:49.080
And the age is say.

01:50.540 --> 01:54.440
Twenty seven VCM.

01:59.470 --> 02:00.360
Plus.

02:01.910 --> 02:06.320
That is given the number of this, say, 12.

02:07.340 --> 02:09.500
And the value can be anything.

02:09.530 --> 02:13.000
So let us give it a value as a list.

02:17.060 --> 02:21.080
Now we can have Cappadocia, so let us.

02:22.650 --> 02:31.200
Played, you sort of have any values, say, one, two, three, and the value will be one.

02:33.540 --> 02:36.630
So here we have.

02:37.870 --> 02:46.790
A key value pair with a key is name a string, the device and the value is, again, a string device.

02:47.380 --> 02:57.420
The next one is a piece with string and value as no key, and we have key as no value as a list here.

02:57.430 --> 03:01.510
We have key as a couple and value as a number.

03:01.990 --> 03:06.570
Let me run this and let us see the dictionary.

03:06.910 --> 03:09.590
So here you can see we are able to create this dictionary.

03:10.480 --> 03:16.140
Now, if you try to create, you can have values as boolean values.

03:16.600 --> 03:19.420
So here I have just created a boolean value.

03:19.630 --> 03:24.850
Now let's try to have a key value pin, which is maybe a list.

03:26.180 --> 03:31.790
Azadeh, so let us read this and let the value of one.

03:33.830 --> 03:41.900
Now, when we run this, you can see the it gives a bipod error, that is the type is unmatchable because

03:41.900 --> 03:44.390
Alist cannot be a part of the key.

03:44.810 --> 03:47.680
So we can simply remove this now.

03:49.450 --> 03:51.310
Let us create another dictionary.

03:52.190 --> 03:55.730
And we will try different operations on the Pacific.

03:58.430 --> 04:01.640
So let's create a dictionary of.

04:04.380 --> 04:05.400
A person.

04:06.380 --> 04:08.270
C student.

04:09.900 --> 04:10.740
And.

04:11.800 --> 04:14.170
Let us create the dictionary.

04:15.580 --> 04:16.070
With.

04:17.190 --> 04:17.940
Name.

04:19.850 --> 04:23.330
As John.

04:28.950 --> 04:30.110
Ange.

04:31.430 --> 04:32.330
14.

04:34.180 --> 04:35.740
Then we can have.

04:37.050 --> 04:38.370
Other details.

04:39.310 --> 04:39.910
Like.

04:41.130 --> 04:42.030
School.

04:44.510 --> 04:47.570
And this is say.

04:49.900 --> 04:50.660
ABC.

04:52.110 --> 04:56.410
So this is the dictionary which we have created and we can print it using STOO.

04:57.150 --> 05:02.010
Now if I want to print a particular value from it.

05:02.040 --> 05:05.470
So remember that a dictionary is unordered in nature.

05:05.490 --> 05:08.010
So if I try to pull something like.

05:09.300 --> 05:10.650
One so.

05:11.870 --> 05:18.610
It will not doing anything because this is not a valid key, what did XM expect?

05:18.710 --> 05:23.080
Here is a key, a key that you have created.

05:23.090 --> 05:24.570
You will have to input that here.

05:25.130 --> 05:28.760
So we will put let's same school.

05:29.600 --> 05:34.260
So if you run this, you will get the value of the school.

05:35.910 --> 05:36.690
Similarly.

05:37.760 --> 05:39.620
If you run this with.

05:40.930 --> 05:43.630
Aneesh, we will get the value of each.

05:44.720 --> 05:51.920
Now, let's say we want to retrieve all the elements from this particular.

05:53.640 --> 06:03.030
Dictionary, then what we can do is we can send see student items and when we done this, we get the

06:03.030 --> 06:07.560
entire value set present in this particular dictionary.

06:08.860 --> 06:10.630
So it returns a list.

06:12.060 --> 06:20.550
All couples, these are the couples, one couple containing key value, next.

06:21.580 --> 06:25.030
The bill, again, contains a key on its value.

06:25.940 --> 06:30.770
Now, let us say we want to retrieve a particular.

06:31.990 --> 06:38.770
Key out of this, so what we can do is for this weekend, statically see.

06:41.110 --> 06:44.530
S.T. Hill, he's.

06:46.020 --> 06:56.070
And it will give me the list of the Indiagames similarly, I can see CD on values and it will give me

06:56.070 --> 07:02.160
the list of all the values which are present now as we have these.

07:02.500 --> 07:11.550
And let us say we want to create a new key value pair, then we can simply cease to and inside this

07:11.550 --> 07:13.890
we can create a new pieszecki.

07:17.450 --> 07:21.230
And I can assign the value to it, see value.

07:22.490 --> 07:30.440
So now, if I didn't do so, you can see a new P-value beard has been added with.

07:38.000 --> 07:46.180
You can see once we have done this, so I knew he was Lupin has been added that he is taken from here

07:46.190 --> 07:48.950
and this is the value which we have just assigned.

07:55.120 --> 07:58.900
Now, let us see how we can delete a particular key value fish.

07:59.970 --> 08:04.500
So let me, first of all, bring the student for you so.

08:09.600 --> 08:10.080
Savi.

08:12.780 --> 08:15.840
And we can get value by using.

08:17.290 --> 08:17.680
He.

08:19.580 --> 08:26.420
So this is the key value pair now, if I want to believe this, I can simply say delete and it will

08:26.420 --> 08:27.940
delete this particular key.

08:29.600 --> 08:32.600
Now, if I look up the dictionary.

08:33.700 --> 08:36.600
Here you can see the value is not available now.

08:38.530 --> 08:47.080
And in case I want to remove the entire dictionary, then I can simply say dill stew and if they leave

08:47.080 --> 08:50.530
the dictionary, so now, if you will, to try to access the dictionary.

08:51.460 --> 08:54.590
It will give an order that is the means do is not defined.

08:55.420 --> 08:58.690
Now let us recreate the dictionary.

09:04.050 --> 09:06.870
So let us recreate this dictionary now.

09:10.300 --> 09:16.720
So this is the collegiate dictionary, which we have the now let's say we want to read on top of this

09:16.720 --> 09:19.930
dictionary, then what we can do is we can simply say for.

09:22.080 --> 09:23.970
Gyi and.

09:25.320 --> 09:27.690
The one that is the dictionary.

09:36.570 --> 09:37.260
Trent.

09:50.000 --> 09:52.830
So this gives me different values.

09:54.170 --> 10:01.430
Now let me try to get the key and the items so that I can do simply by.

10:25.430 --> 10:27.810
So this gives me the key and relevant.

10:28.550 --> 10:36.260
Now let us say we want to trade on top of both key in value and we don't really want to use this particular

10:36.260 --> 10:41.420
structure because we might not really know which dictionary we are working on.

10:41.690 --> 10:43.870
So we can simply use the same thing.

10:44.570 --> 10:49.200
But the difference will be now we will try to get more value here.

10:49.300 --> 10:54.980
So now we will be trading on the dictionary items so that items.

10:57.220 --> 10:59.740
Now, what does dictionary those items give us?

11:01.030 --> 11:03.860
So let us see what the one item will give us.

11:04.360 --> 11:13.150
So this gives us the Thumper's that is the key and the corresponding value on the key, on its corresponding

11:13.150 --> 11:14.120
value and so on.

11:14.590 --> 11:17.380
So then we will be getting the values.

11:17.390 --> 11:18.130
This will be.

11:19.300 --> 11:27.160
In fact, so we will get key karma value from it, so instead of using this, we can simply say value

11:29.170 --> 11:31.560
and this will bring the key and value the.

11:33.270 --> 11:42.630
So this is how we can access elements from a dictionary and use it in a for loop, so always remember,

11:42.630 --> 11:48.320
if you want to access a particular dictionary, then we will be using keys for accessing the dictionary.

11:48.870 --> 11:54.370
So whenever we will be looping on a dictionary, it will loop on the keys.

11:54.570 --> 11:59.880
So we will get keys here and then we can decode corresponding key and values.

12:00.480 --> 12:04.740
Now is we are moving on the items.

12:04.740 --> 12:12.000
This means that we are looping on this particular list of papers which contains key and value mode.

12:12.240 --> 12:19.590
So it will be unpacked and we get key and value in this particular order, only that the values will

12:19.590 --> 12:22.660
always be the first one which we will be getting would be key.

12:22.920 --> 12:25.770
And the second one which we will be getting is the value.

12:26.640 --> 12:28.310
So this is about dictionaries.

12:28.770 --> 12:29.370
Thank you.
