WEBVTT

00:00.320 --> 00:01.040
Hello guys.

00:01.040 --> 00:03.500
So we are going to continue the discussion with respect to Python.

00:03.500 --> 00:08.120
And now we are going to discuss about our new data structure which is called as dictionaries.

00:08.120 --> 00:13.010
So in this video this is the entire video outline where we will be discussing about the introduction

00:13.010 --> 00:13.880
to dictionaries.

00:13.880 --> 00:16.670
We will be creating dictionaries with the help of Python.

00:16.700 --> 00:20.750
How to access the dictionary elements, modifying dictionary elements.

00:20.930 --> 00:26.360
Then we'll be seeing some of the amazing dictionary methods that we usually use while we are developing

00:26.360 --> 00:27.200
projects.

00:27.320 --> 00:30.620
Along with that, we'll also be iterating over dictionaries.

00:31.160 --> 00:35.600
Then we will be discussing about nested dictionaries, then dictionary comprehension.

00:35.600 --> 00:40.220
And finally we will be seeing some of the common errors that we usually face.

00:40.430 --> 00:46.340
Now in this it is very much important that we probably do a lot of practicals.

00:46.340 --> 00:50.480
So that is the reason I will be showing you each and everything with the help of coding.

00:50.510 --> 00:51.860
Now let me go ahead.

00:51.860 --> 00:55.220
And first of all, uh, let's see the definition of dictionaries.

00:55.220 --> 00:59.210
So dictionaries are nothing, but it is an unordered collection of items.

00:59.210 --> 01:02.490
The store data in key value pairs.

01:02.520 --> 01:02.790
Okay.

01:02.820 --> 01:08.040
So they're all the data is basically stored in key value pairs.

01:08.070 --> 01:10.890
Key must be unique and immutable.

01:10.920 --> 01:14.280
So once you specifically define a key it cannot be changed.

01:14.280 --> 01:15.750
Values can be changed.

01:15.750 --> 01:19.290
And a key must always be unique.

01:19.320 --> 01:19.740
Okay.

01:19.770 --> 01:25.860
And it can include strings numbers or tuples uh which while values can be of any type.

01:25.890 --> 01:26.370
Okay.

01:26.370 --> 01:30.000
So let me just go ahead and I hope you have just understood the definition.

01:30.000 --> 01:32.790
But again to make you understand much more in a better way.

01:32.820 --> 01:38.190
First of all, we will go ahead, uh, in discussing about creating dictionaries.

01:38.220 --> 01:38.760
Okay.

01:38.790 --> 01:43.530
Now with respect to creating dictionaries, first of all, what we are really going to do over here

01:43.530 --> 01:46.170
is that create an empty dictionary.

01:46.200 --> 01:49.590
Now, already, you know, if I use square braces okay.

01:49.620 --> 01:51.990
And before that make sure you select the kernel.

01:52.470 --> 01:58.440
Uh, so if you are basically using this square brackets then you basically create an empty list.

01:58.440 --> 02:01.450
If you are using tuples, you create an empty tuple.

02:01.480 --> 02:04.660
Now in case of dictionary we use flower braces.

02:04.690 --> 02:09.790
Okay, now let's go ahead and define and create our empty dictionary.

02:09.820 --> 02:18.730
So here you can see if I go ahead and print type of empty dictionary, you will be able to see that

02:18.730 --> 02:21.340
I will be getting a class which is called as dictionary.

02:21.370 --> 02:26.980
So in order to create an empty dictionary, all we have to do is that we have to specifically use this

02:26.980 --> 02:27.970
flower braces.

02:28.000 --> 02:28.510
Okay.

02:28.540 --> 02:35.680
Another way how we can actually create our empty dictionary is that by using this dict class.

02:35.710 --> 02:36.250
Okay.

02:36.280 --> 02:39.100
And here we will initialize it as a method.

02:39.100 --> 02:41.950
So once we initialize it here you will be able to see.

02:41.980 --> 02:46.060
Now again I will be getting an complete empty dictionary.

02:46.090 --> 02:46.450
Okay.

02:46.480 --> 02:48.490
So right now it is a complete empty dictionary.

02:48.490 --> 02:53.710
So these are the two ways of specifically creating an empty dictionary.

02:53.740 --> 02:58.340
Now, as I have already said, that dictionary is all about key value pairs.

02:58.370 --> 03:02.240
Right now, whenever we talk about key value pairs, let me just give you an example.

03:02.240 --> 03:03.230
So key.

03:03.560 --> 03:07.850
So initially we will start writing in this flower brackets.

03:07.850 --> 03:12.350
So first of all what we are going to do is that we are going to give my key name, let's say one of

03:12.350 --> 03:15.440
the key name with respect to student information is name.

03:15.440 --> 03:18.290
And let me just go ahead and write the name called as Krish.

03:18.320 --> 03:18.800
Okay.

03:18.800 --> 03:20.060
So Krish is the name.

03:20.060 --> 03:21.650
So this basically becomes the key.

03:21.680 --> 03:24.020
This basically becomes the value okay.

03:24.050 --> 03:28.970
Now the next thing is that I will go ahead and use my another key which is called as age.

03:29.540 --> 03:29.960
Okay.

03:29.990 --> 03:34.730
And here we are specifically going to use a value let's say 32 okay.

03:34.760 --> 03:39.320
Third I'm just going to use another key which is called as grade.

03:39.950 --> 03:45.320
Now if I go ahead and write this, you will be able to see if I go ahead and print this student.

03:45.350 --> 03:51.920
This is a complete dictionary where I have three keys, that is name, age and grade.

03:51.920 --> 03:55.490
And the values are Krish 32 and 24.

03:55.940 --> 03:57.810
Now if I go ahead and print the student.

03:57.810 --> 04:01.170
So this basically becomes my entire dictionary, right?

04:01.170 --> 04:02.820
Which has this key value pairs.

04:02.820 --> 04:10.110
If you want to also check out the print of type of student, you will also be able to see that I'm able

04:10.110 --> 04:11.760
to get a dictionary over here.

04:11.790 --> 04:12.240
Okay.

04:12.270 --> 04:17.580
So this is how you specifically create a dictionary with the help of key value pairs.

04:17.610 --> 04:18.090
Okay.

04:18.120 --> 04:21.210
Now let me just show you one more thing here.

04:21.210 --> 04:22.590
When do you get an error.

04:22.590 --> 04:26.070
Because as I said to you, that key should be unique okay.

04:26.070 --> 04:31.890
So let's say if I go ahead and copy this and paste it over here and again I use the same name.

04:31.890 --> 04:33.420
Now what is going to happen.

04:33.450 --> 04:34.050
Okay.

04:34.050 --> 04:36.780
And I'll just go ahead and print student.

04:36.810 --> 04:40.170
Let's see what is going to happen.

04:40.170 --> 04:45.060
Because you really need to understand whether we will get an error or whether it will just print out.

04:45.060 --> 04:49.980
So here you can see only two keys are basically getting their name and age right.

04:50.010 --> 04:51.840
Name is having the value of 24.

04:51.870 --> 04:52.560
Age is 32.

04:52.590 --> 04:54.750
Now what has exactly happened over here?

04:54.750 --> 04:57.160
Now when I'm writing name is equal to Krish.

04:57.160 --> 04:59.800
This was one of the key that I have already defined.

04:59.830 --> 05:05.890
Now, if I'm again defining this particular key, you know, in the upcoming, like in the key value

05:05.890 --> 05:07.750
pairs, then what it is going to do.

05:07.780 --> 05:09.940
The value is getting going to get replaced.

05:09.970 --> 05:10.480
Okay.

05:10.480 --> 05:13.330
But it is going to consider as one key itself.

05:13.330 --> 05:18.340
So which is the recent value that you have replaced over here the value that is what is getting displayed.

05:18.340 --> 05:24.370
So always please make sure that here you don't have to always create the key with the same name.

05:24.400 --> 05:29.500
I'll not say this as an error, but here you can see that, uh, I can just write.

05:29.500 --> 05:31.750
Single key is always used okay.

05:32.440 --> 05:33.700
Instead of multiple keys.

05:33.700 --> 05:35.710
So this is one super example.

05:35.710 --> 05:41.440
And this will be very much important because, see, um, if you know about databases now NoSQL databases

05:41.440 --> 05:47.710
like MongoDB, like Cassandra over there, now all key value pairs will be specifically used, right.

05:47.710 --> 05:49.660
All your data will be stored in key value pairs.

05:49.660 --> 05:56.450
So it is important that we always need to have this key unique right now, let me just go ahead and

05:56.450 --> 06:01.760
let me talk about accessing dictionary elements.

06:01.790 --> 06:02.330
Okay.

06:02.360 --> 06:05.240
Now with respect to accessing dictionary elements.

06:05.270 --> 06:12.770
Now what I'm actually going to do, let me just go ahead and make this as uh, or I'll just copy this.

06:13.160 --> 06:13.760
Okay.

06:13.760 --> 06:16.310
And let me copy this over here.

06:17.030 --> 06:17.480
Oops.

06:17.510 --> 06:18.080
Not here.

06:18.080 --> 06:18.440
Sorry.

06:18.470 --> 06:19.100
Here.

06:19.220 --> 06:22.100
And let me just make this grade as a.

06:22.190 --> 06:22.940
Okay.

06:23.450 --> 06:27.080
Now, this is my entire dictionary, right?

06:27.110 --> 06:32.060
Now, if I want to access any value, let's say I want to access the value of grade.

06:32.090 --> 06:32.780
Okay.

06:32.900 --> 06:34.460
Now, how do I do it?

06:34.490 --> 06:36.530
We definitely have to use this key.

06:36.560 --> 06:44.570
So what I will be doing is that I will just say student of I want the grade of this particular student.

06:44.570 --> 06:49.040
So I will just give the key name over here and let me just go ahead and print it.

06:49.070 --> 06:49.640
Okay.

06:49.640 --> 06:52.940
So here once I do the print over here right?

06:52.940 --> 06:55.020
I should be able to get see the grid.

06:55.050 --> 06:58.680
Similarly, let's say I want to go ahead and get the age.

06:59.760 --> 07:01.050
So I will go ahead and write.

07:01.050 --> 07:06.360
Student of student of age.

07:07.500 --> 07:07.830
Right.

07:07.830 --> 07:10.320
And if I go ahead and print it it is 32.

07:10.350 --> 07:10.800
Right.

07:10.800 --> 07:16.410
So this is one of the method of accessing I'll write it down over here.

07:16.410 --> 07:20.640
Accessing dictionary elements okay.

07:20.670 --> 07:24.540
This is one of the easiest way to probably do it.

07:24.540 --> 07:33.330
There is also one way where we will be able to access the values using the default get method that is

07:33.330 --> 07:35.700
provided by the dictionary.

07:35.850 --> 07:38.430
Okay, get method that is provided by dictionary.

07:38.460 --> 07:40.770
Now how to do this, I will just show you.

07:40.860 --> 07:44.130
Okay, so first of all I will just go ahead and write print.

07:44.280 --> 07:47.040
Let's say I want to get the grade right.

07:47.070 --> 07:49.080
What is the grade of this particular student.

07:49.080 --> 07:55.240
So I will just go ahead and use dot get and here I'm just going to give my key name that is Dot grid.

07:55.270 --> 07:55.690
Okay.

07:55.720 --> 08:00.160
Similarly, let's say if I want to go ahead and print student dot.

08:00.520 --> 08:10.690
And uh, let's say I want to probably, um, you know, let's say that there is no like over here.

08:10.690 --> 08:13.090
The key that are available are name, age, grade.

08:13.120 --> 08:13.630
Right.

08:13.660 --> 08:17.020
Let's say I will go ahead and search for last name.

08:17.530 --> 08:17.890
Okay.

08:17.920 --> 08:19.870
I know the key is not present over there.

08:19.870 --> 08:23.170
So let's see what is the value that I will be getting.

08:23.200 --> 08:23.740
Okay.

08:23.740 --> 08:26.980
And by using get we will be able to get the value anyhow.

08:26.980 --> 08:29.200
But if I execute it here you'll be able to see.

08:29.230 --> 08:30.910
First student grade.

08:30.910 --> 08:32.470
I got a student age.

08:32.470 --> 08:33.910
I got 32 again.

08:33.910 --> 08:37.270
When I'm writing student dot get of grade I can get a.

08:37.300 --> 08:42.070
But when I'm searching for last name, I'm not getting anything right.

08:42.070 --> 08:43.540
I'm getting it as none.

08:43.630 --> 08:49.300
Now let's say that, uh, if I find out if I don't find any key, I want to probably give a default

08:49.300 --> 08:49.840
value.

08:49.840 --> 08:51.920
So for that, I will go ahead and write.

08:52.250 --> 08:53.030
Print.

08:53.060 --> 08:54.260
Student.

08:54.650 --> 08:55.730
Student.

08:55.760 --> 08:56.450
Dot.

08:56.450 --> 08:57.260
Get.

08:57.290 --> 08:57.920
Okay.

08:58.130 --> 09:04.250
And here I'm going to specifically write last underscore name I know last number underscore name key

09:04.250 --> 09:05.270
is not available.

09:05.270 --> 09:08.930
But I will give a default value if it is not available.

09:08.960 --> 09:10.460
So I'll write not available.

09:10.490 --> 09:13.130
Now let's see the value that we are going to get.

09:13.160 --> 09:14.150
So see over here.

09:14.150 --> 09:16.460
Last name was not present in this particular key.

09:16.460 --> 09:20.720
So I am getting the default value which I have provided it over here as not available.

09:20.720 --> 09:22.340
So before it was giving us none.

09:22.340 --> 09:25.490
Now it is probably giving us not available right.

09:25.520 --> 09:30.800
So this is how with the help of key, you will be able to access it.

09:30.800 --> 09:34.220
And two ways I've actually shown you how to access dictionary elements.

09:34.310 --> 09:39.470
Either you are directly calling the key or you are using the Get method right.

09:39.500 --> 09:48.290
Now let me just go ahead and let me talk about the next method that is called as modifying dictionary

09:49.430 --> 09:50.030
Elements.

09:50.060 --> 09:50.660
Okay.

09:50.900 --> 09:57.410
Now with respect to modifying dictionary elements, one very important key that I really want to write

09:57.440 --> 09:57.830
right?

09:57.860 --> 10:00.260
Dictionary are mutable.

10:00.590 --> 10:00.980
Right.

10:00.980 --> 10:09.020
So you can add, update, update or delete elements okay.

10:09.050 --> 10:12.080
So this is the most important thing about dictionary.

10:12.080 --> 10:14.000
But you cannot see.

10:14.000 --> 10:17.870
You cannot like always all the time your key needs to be unique right.

10:17.900 --> 10:19.070
At any point of time.

10:19.070 --> 10:23.150
So let me just go ahead and show you some of the examples over here.

10:23.180 --> 10:27.020
So let us go ahead and discuss about modifying dictionary elements.

10:27.530 --> 10:33.620
So here already let us go ahead and print this students.

10:33.620 --> 10:34.310
Right.

10:35.090 --> 10:38.840
And here you can see the name is the key.

10:38.870 --> 10:42.020
The key name is basically having the value.

10:42.050 --> 10:43.700
Krish age is 32.

10:43.700 --> 10:44.690
Grade is eight.

10:44.840 --> 10:46.850
Now let me do one thing.

10:46.850 --> 10:49.680
Let me just go ahead and add a new key.

10:49.710 --> 10:53.430
I'll also be showing how to add a new key and also updating let's say age.

10:53.460 --> 11:01.800
So here now if I go ahead and write student of age and let's say the age is now 33 okay.

11:01.830 --> 11:06.390
And I'm just going to print the student.

11:06.840 --> 11:11.520
Now along with that, what I'm actually going to do is that I'm going to add a new key.

11:11.550 --> 11:14.880
And the new key will be something like address.

11:15.480 --> 11:16.050
Okay.

11:16.410 --> 11:21.000
And let me just go ahead and write the address as India okay.

11:21.060 --> 11:23.910
So this is the new key that I'm specifically adding.

11:23.940 --> 11:27.750
Now I will go ahead and print the student.

11:29.760 --> 11:35.880
Now here you can actually see that the first key age has got updated to 33.

11:35.910 --> 11:41.400
Now once it got updated I again added a new key over here which is called as address.

11:41.400 --> 11:48.190
So now I will be able to see the address India that has been added to the same student dictionary Okay.

11:48.460 --> 11:51.910
Along with this, we can also go ahead and delete any key.

11:51.940 --> 11:52.510
Right.

11:52.510 --> 11:56.860
So what I'm actually going to do is that I'm going to delete the key over here.

11:56.890 --> 11:57.310
Okay.

11:57.310 --> 11:59.860
Let's consider that I'm going to delete the grid key.

11:59.860 --> 12:01.600
So let's go ahead and see that.

12:02.470 --> 12:12.250
So here what we have actually done we have updated the value for the key right here we have added a

12:12.250 --> 12:19.930
new key and value added a new key and value.

12:21.640 --> 12:27.370
And in the next statement what I'm actually going to do is that I'm going to delete the key.

12:27.370 --> 12:32.530
So in order to delete the key I just need to use this del keyword okay.

12:32.560 --> 12:34.330
That is available in Python.

12:34.330 --> 12:36.610
And I will be using the student.

12:36.610 --> 12:38.440
And let me just give the key name.

12:38.440 --> 12:45.190
So if I go ahead and write like this, this will basically delete the key and value pair.

12:45.760 --> 12:46.450
Okay.

12:46.460 --> 12:56.270
Now, if I go ahead and print the student, you will be able to see that I will now have that entire

12:56.270 --> 12:57.410
key, right?

12:57.440 --> 13:00.200
Grade has got deleted along with the value.

13:00.200 --> 13:06.620
And I just have the remaining key that is key value pairs like name crush, age 33 address India okay,

13:06.650 --> 13:09.230
so this is how you delete the key value pair.

13:09.230 --> 13:13.280
So these are some of the operations and how we can modify dictionary elements.

13:13.310 --> 13:13.820
Okay.

13:14.420 --> 13:21.620
Um now let me just go ahead and show you some of the dictionary common dictionary methods that we use.

13:21.800 --> 13:22.370
Okay.

13:23.090 --> 13:29.030
Now you will be also seeing more examples because after this I will be also showing showing some use

13:29.030 --> 13:30.080
cases examples okay.

13:30.110 --> 13:33.320
So there again we will be discussing more about dictionaries okay.

13:33.380 --> 13:38.210
Now some of the important dictionary methods okay.

13:38.240 --> 13:39.920
So first of all let me just go ahead.

13:39.920 --> 13:44.780
Let's say you just want to get the all the keys of that particular dictionary okay.

13:44.780 --> 13:46.740
So I will go ahead and write.

13:46.770 --> 13:54.510
Keys is equal to student, which is my dictionary student dot keys.

13:54.540 --> 13:55.320
Okay.

13:56.010 --> 13:59.370
And let me just go ahead and print all the keys over here.

13:59.640 --> 14:02.580
Okay then let me just go ahead and write.

14:02.580 --> 14:06.810
Values is equal to student dot values.

14:07.050 --> 14:07.710
Okay.

14:07.890 --> 14:14.970
If I want to get the values right off all the dictionary that I have basically in the dictionary, all

14:14.970 --> 14:17.820
the values that I if I want all the values, how can I get it.

14:17.820 --> 14:22.890
So this first code that I've actually written, this will actually help you to get all the keys.

14:23.070 --> 14:23.610
Okay.

14:23.640 --> 14:28.290
And this will actually help you to get all the values.

14:28.320 --> 14:28.830
Okay.

14:28.980 --> 14:33.780
And if I go ahead and print the values I will be able to see the values over here.

14:34.350 --> 14:35.190
Uh, one more.

14:35.220 --> 14:42.240
Uh, let's say I want to get all the key value pairs, let's say in the form of items.

14:42.270 --> 14:42.690
Okay.

14:42.900 --> 14:46.810
How do I get the key value pairs right in that case.

14:46.810 --> 14:48.220
So let me just go ahead and write.

14:48.220 --> 14:50.530
And I'll define a variable called as items.

14:50.530 --> 14:55.900
And if I go ahead and write student dot items right.

14:55.900 --> 15:02.440
And this will actually help me to get all key value pairs okay.

15:02.560 --> 15:08.080
Now let me just go ahead and print this specific items okay.

15:08.350 --> 15:12.310
So here you can see that uh let's see the first one okay.

15:12.340 --> 15:14.290
Student Dot keys I'm getting all the key.

15:14.320 --> 15:16.120
So name age and address are the key.

15:16.150 --> 15:18.820
When I wrote student dot values I got all the values.

15:18.820 --> 15:19.630
So I'm printing it.

15:19.630 --> 15:21.490
So 33 and India.

15:21.520 --> 15:24.160
And when I want all the key value pairs.

15:24.160 --> 15:26.080
So like this I'm able to get it right.

15:26.080 --> 15:31.270
So this will be a new type which is called as dictionary items which will be in the form of list of

15:31.270 --> 15:31.750
tuples.

15:31.750 --> 15:33.700
So these are nothing but tuples right.

15:33.730 --> 15:35.200
Tuples tuples tuples.

15:35.230 --> 15:37.720
Right I will be able to access this particular tuples also.

15:37.720 --> 15:39.610
And it is a list of tuples okay.

15:39.640 --> 15:44.000
So here you can see name Krish age 33 A Address?

15:44.000 --> 15:45.740
India right now.

15:45.740 --> 15:46.460
One more thing.

15:46.490 --> 15:50.030
Uh, I really want to do is do a shallow copy.

15:50.060 --> 15:53.480
Okay, now let us discuss about shallow copy over here.

15:53.480 --> 15:57.290
So, guys, now let me just go ahead and show you the working of shallow copy.

15:57.290 --> 15:59.390
And this is something really, really important.

15:59.390 --> 16:01.910
And trust me, you should never do this mistake.

16:01.910 --> 16:07.460
Whenever you are implementing in any kind of project, you have to make sure that whenever, uh.

16:07.460 --> 16:12.710
And you need to remember this concept because this can be a very small mistake whenever you are developing

16:12.710 --> 16:13.280
projects.

16:13.310 --> 16:13.880
Okay.

16:13.940 --> 16:19.130
Now I have student dictionary over here right now.

16:19.130 --> 16:20.000
Let me do one thing.

16:20.000 --> 16:22.250
Let me create another variable.

16:22.250 --> 16:25.010
Let's say I will go ahead and write student underscore copy.

16:25.010 --> 16:27.530
And I will assign the student value over here.

16:27.530 --> 16:32.060
And as you all know what is present in the student, the key value pairs.

16:32.060 --> 16:41.900
Right now if I go ahead and print student and if I go ahead and print student underscore copy, okay.

16:43.410 --> 16:45.690
Student underscore copy.

16:45.810 --> 16:47.130
What am I getting?

16:47.160 --> 16:48.600
I'm getting the same value.

16:48.630 --> 16:49.680
This is perfectly fine.

16:49.680 --> 16:54.030
And obviously since I'm copying this particular value to another variable.

16:54.030 --> 16:57.150
So this will also be a dictionary that will be having the same value over here.

16:57.180 --> 16:57.810
Okay.

16:58.290 --> 17:05.010
But now what I will do I will just go ahead and take student name value.

17:05.340 --> 17:05.820
Right.

17:05.850 --> 17:08.370
Student name value.

17:08.490 --> 17:11.100
And I will assign some other value itself.

17:11.130 --> 17:11.310
Right.

17:11.340 --> 17:12.450
Let's say Chris one.

17:12.480 --> 17:13.140
Okay.

17:13.200 --> 17:19.560
Now let me just go ahead and print student and let me print the same student underscore copy.

17:20.730 --> 17:25.530
What do you think should be the name in student underscore copy.

17:26.250 --> 17:27.240
Should it be Chris.

17:27.270 --> 17:28.170
1 or 2.

17:28.200 --> 17:29.700
Okay I'll make it to Chris two.

17:29.730 --> 17:30.240
Okay.

17:30.360 --> 17:35.820
Let's say I'm changing the name of this particular student right over here to Chris two.

17:36.000 --> 17:41.040
Now, since I'm making the change to this student dictionary, since I have made a copy of this in student

17:41.050 --> 17:42.070
underscore copy.

17:42.100 --> 17:43.870
Then you may be thinking okay.

17:43.900 --> 17:47.740
Student underscore copy should still have one, but it does not happen in that way.

17:47.740 --> 17:52.450
If I go ahead and see the output, you'll be seeing that since student also got the name as Chris two

17:52.480 --> 17:55.210
since we had assigned the value to student underscore copy.

17:55.240 --> 17:57.460
So here also we are getting Chris two.

17:57.550 --> 17:59.740
And this is a big problem right.

17:59.740 --> 18:02.500
So how do I make a separate copy.

18:02.530 --> 18:07.840
You know whenever I probably want to make a copy for this particular dictionary to another variable

18:07.870 --> 18:13.570
in such a way that after that if I update this, the same update should not happen in your copy variable.

18:13.570 --> 18:17.350
So for that I will be showing you about shallow copy.

18:17.380 --> 18:23.020
Now in shallow copy, what we do is that let's say I go ahead and create my student copy one variable.

18:23.050 --> 18:26.230
I will go ahead and write student dot copy function.

18:26.260 --> 18:26.800
Okay.

18:26.830 --> 18:31.000
Now this copy function is responsible for doing the shallow copy over here.

18:31.000 --> 18:35.530
In short if you really want to understand this will basically allocate a different memory.

18:35.680 --> 18:40.880
It will take this variable and it will give the reference of this variable to another memory which will

18:40.880 --> 18:43.970
have that entire value that we really want to store.

18:44.030 --> 18:52.550
Okay, now if I go ahead and print student underscore copy student underscore copy one.

18:52.580 --> 18:53.180
Okay.

18:53.210 --> 18:57.530
And if I go want to go ahead and print student.

18:57.560 --> 18:58.310
Right.

18:58.310 --> 19:01.880
And if I execute it now here you can see okay I'm having the same value.

19:01.910 --> 19:06.980
But now let me just update the student name.

19:07.910 --> 19:08.540
Okay.

19:08.840 --> 19:12.920
If I go ahead and update the student name let's say if I go ahead and write Krish three.

19:13.100 --> 19:13.910
Okay.

19:14.120 --> 19:19.220
Now if I go ahead and print both of them, will I get the same value of the name?

19:19.250 --> 19:20.900
The answer is no.

19:20.930 --> 19:25.160
See, I will execute this now in my student underscore copy one.

19:25.160 --> 19:26.630
I still have Krish two.

19:27.020 --> 19:29.120
In student I have Krish three.

19:29.150 --> 19:29.750
Right.

19:29.750 --> 19:31.220
And why this was possible?

19:31.250 --> 19:33.380
Because of the shallow copy itself, right.

19:33.410 --> 19:37.970
So just get an idea about shallow copy or shallow copy in turns.

19:37.970 --> 19:43.980
You know, Provides a different memory location so that whenever we change one of the variable, it

19:43.980 --> 19:45.180
should not impact the other one.

19:45.210 --> 19:50.490
Okay, so just a smaller thing to understand over here because this will be important when you are doing

19:50.490 --> 19:51.180
the coding.

19:51.300 --> 19:58.110
Now let's go ahead and discuss about iterating over dictionaries.

19:58.230 --> 19:59.070
Okay.

19:59.820 --> 20:04.560
First thing you can use loops to iterate.

20:04.560 --> 20:11.400
Like how did we do in the in the in the case of list or in the case of tuples.

20:11.730 --> 20:14.970
So here also we are specifically.

20:15.510 --> 20:16.680
Okay I'll write.

20:16.710 --> 20:18.720
You can use.

20:18.750 --> 20:19.200
Okay.

20:19.230 --> 20:22.920
Loops to iterate.

20:23.850 --> 20:26.580
And we can iterate over dictionaries.

20:26.580 --> 20:28.440
And you know in dictionaries.

20:28.440 --> 20:35.010
Uh, if I probably talk about we have keys, we have values or we have items.

20:35.010 --> 20:37.560
Items basically means the combination of key and value pair.

20:37.570 --> 20:38.170
right?

20:38.200 --> 20:40.630
So let me just go ahead and show you the same example.

20:40.630 --> 20:43.660
Let's say that this is my student variable okay.

20:43.720 --> 20:47.470
And for this particular student I will go ahead and iterate through each and everything.

20:47.470 --> 20:53.080
So first of all I will try to show you iterating over keys okay.

20:53.110 --> 20:59.710
Now iterating over keys for keys in again we'll use a for loop and I will just go ahead and write student

20:59.710 --> 21:00.400
dot keys.

21:00.400 --> 21:04.630
When I write student dot keys, obviously you'll be able to see that I'll be getting the keys itself.

21:04.630 --> 21:08.590
If I go ahead and print the key, you'll be able to see.

21:09.040 --> 21:09.670
Oops.

21:10.150 --> 21:10.750
Uh, keys.

21:10.750 --> 21:11.320
Sorry.

21:11.650 --> 21:14.560
You'll be able to see name, age, and address.

21:14.560 --> 21:16.780
These are the keys that I have actually defined.

21:16.810 --> 21:25.660
Similarly, you can iterate iterate over values.

21:25.960 --> 21:29.050
And for that what you need to do again copy the same thing.

21:29.320 --> 21:29.860
Right.

21:29.890 --> 21:32.320
Paste it over here instead of student dot keys.

21:32.320 --> 21:37.280
Now you go ahead and write student dot values Okay.

21:37.310 --> 21:43.670
And once I go ahead and write it over here, I can print it over here itself.

21:43.670 --> 21:46.970
And this is what you will be able to get a value three.

21:47.000 --> 21:49.280
You will be able to get 33 India.

21:49.310 --> 21:49.910
Okay.

21:49.970 --> 22:06.260
Now if I want to iterate iterate over key value pairs then what we really need to do I will be using

22:06.290 --> 22:08.540
two variable in my for loop.

22:08.570 --> 22:15.500
One is key comma value and student dot items.

22:16.850 --> 22:21.590
And now I will just go ahead and print by using an f string.

22:21.860 --> 22:22.340
Okay.

22:22.340 --> 22:24.980
So this is one way of formatting.

22:25.220 --> 22:28.970
In print formatting I can go ahead and write my key.

22:29.660 --> 22:32.570
Along with this I can go ahead and write my value.

22:33.410 --> 22:34.550
If I go ahead and see this.

22:34.550 --> 22:37.210
This is my age Three age.

22:37.330 --> 22:37.630
Sorry.

22:37.660 --> 22:38.500
Name three.

22:38.530 --> 22:39.370
Age 33.

22:39.400 --> 22:40.360
Address India.

22:41.440 --> 22:44.290
So you can also iterate over the key value pairs.

22:44.290 --> 22:49.630
And just by writing student dot items, you get that value in tuples right in list of tuples.

22:49.630 --> 22:54.490
So all these things you can basically work and you can basically iterate over the dictionaries.

22:54.520 --> 23:01.960
Now talking about the next one, uh, here we are going to go ahead with let me make some cells okay.

23:02.020 --> 23:07.780
So we are going to talk about nested dictionaries okay.

23:08.080 --> 23:12.640
Now nested dictionaries a dictionary inside another dictionary okay.

23:12.820 --> 23:15.700
And usually if I talk about databases MongoDB.

23:15.730 --> 23:16.180
Right.

23:16.210 --> 23:17.740
NoSQL database over there.

23:17.740 --> 23:19.510
Everything is stored in key value pair.

23:19.510 --> 23:23.620
Whenever we say key value pair later on we can read that, convert that into a dictionary.

23:23.620 --> 23:27.010
And I may have any number of records in the MongoDB database.

23:27.010 --> 23:27.460
Right.

23:27.460 --> 23:29.350
So let me just go ahead and do one thing.

23:29.380 --> 23:34.600
Let me go ahead and write students, and let me just show you how you can create key value pairs Okay,

23:35.080 --> 23:37.180
so let's say this is my first key.

23:37.180 --> 23:42.820
That is nothing but student one and I will just go ahead and write my key value pair here.

23:42.820 --> 23:54.340
The first thing I will go and see name name is let's say Krish uh, age is let's say colon 32.

23:54.370 --> 23:55.000
Okay.

23:55.090 --> 23:57.790
And uh, age 32.

23:57.790 --> 24:00.340
And here I am specifically creating this.

24:00.370 --> 24:01.000
Right.

24:01.030 --> 24:01.330
Sorry.

24:01.360 --> 24:05.260
It should be colon not equal to colon 32.

24:05.290 --> 24:05.860
Okay.

24:06.070 --> 24:07.720
This is my first record.

24:07.840 --> 24:08.200
Yeah.

24:08.650 --> 24:11.050
Now let me go ahead and create my second record.

24:11.050 --> 24:13.180
Let's say I may have student two data.

24:13.930 --> 24:18.730
And now with respect to this particular student two data I may have name.

24:19.300 --> 24:20.770
Name is nothing.

24:20.770 --> 24:32.080
But let's say Krish or I'll just say, um, Spider-Man or Peter Parker or anyone.

24:32.110 --> 24:32.350
Right?

24:32.380 --> 24:34.160
So Peter right?

24:34.970 --> 24:39.230
Age is nothing but let's say 35, right?

24:39.260 --> 24:41.480
So here you can see key value pairs.

24:41.780 --> 24:42.410
Right.

24:42.410 --> 24:45.860
And this is nothing but this is basically a nested dictionary right.

24:45.890 --> 24:51.620
Now if I go ahead and print students you will be able to see that.

24:51.650 --> 24:53.510
Hey it looks like a dictionary.

24:53.540 --> 24:54.530
Key value pairs.

24:54.560 --> 24:56.840
Again it can have nested key value pairs.

24:56.870 --> 24:57.500
Right.

24:57.500 --> 25:04.190
But these are just like a kind of records like how we upload it in MongoDB or in any other non SQL databases

25:04.220 --> 25:05.270
NoSQL databases.

25:05.300 --> 25:05.930
Right.

25:05.960 --> 25:08.090
Now how do we access this.

25:08.090 --> 25:17.480
Nested dictionaries access nested dictionaries dictionaries elements okay.

25:17.480 --> 25:22.070
So I will just go ahead and print right students.

25:24.290 --> 25:29.480
And here I'm going to use let's say I want to read the Age of Peter Parker.

25:29.510 --> 25:30.470
Then how do I right.

25:30.470 --> 25:31.610
So I will just go ahead and write.

25:31.610 --> 25:34.050
Student Student two okay.

25:34.080 --> 25:39.900
And the next bracket will be specifically name okay or name or age.

25:39.900 --> 25:43.260
I can also get name if I want to print, I can print name.

25:43.260 --> 25:48.480
Let's say if I go ahead and print this entire information along with age, here I will be getting age

25:48.480 --> 25:49.560
or name of Peter Parker.

25:49.560 --> 25:52.230
And here I will be getting the age right.

25:52.230 --> 25:55.620
So if I go and see Peter and 35 right.

25:55.620 --> 26:00.270
So here with respect to the nested dictionaries, also like how we read in in nested list.

26:00.300 --> 26:02.730
Similarly we can go ahead and do that here.

26:02.730 --> 26:05.340
The main thing is that we only have to call the key names.

26:05.340 --> 26:08.370
And automatically you will be able to get the value names right.

26:08.370 --> 26:11.700
So this is one amazing way of playing with nested dictionaries.

26:11.730 --> 26:12.270
Okay.

26:12.300 --> 26:15.690
Now uh, again you can try multiple example.

26:15.690 --> 26:17.910
You can create your own nested dictionaries.

26:17.910 --> 26:19.680
Any level of nested dictionaries.

26:19.920 --> 26:22.200
Uh, there is no limit as such inside name.

26:22.200 --> 26:25.590
Also, you can again go ahead and create another nested dictionary if you want.

26:25.620 --> 26:26.160
Okay.

26:26.370 --> 26:29.100
Now let me just go ahead and show you one more thing.

26:29.130 --> 26:34.300
Iterating Over nested dictionaries.

26:34.330 --> 26:37.570
Okay, now for let's say I will go ahead and write.

26:37.600 --> 26:38.860
For student underscore ID.

26:39.250 --> 26:39.940
Okay.

26:39.970 --> 26:42.430
Since I require ID and information.

26:42.430 --> 26:44.830
So let's say I will go ahead and write like this.

26:44.920 --> 26:45.700
Just see this.

26:45.730 --> 26:46.150
Okay.

26:46.180 --> 26:48.610
Student underscore info.

26:48.640 --> 26:53.170
Okay I will consider this as ID and this as entire info okay.

26:53.320 --> 26:54.670
And if I go ahead and write.

26:54.700 --> 27:01.900
Students students students okay.

27:01.990 --> 27:03.970
Dot items.

27:04.360 --> 27:09.820
So what will student dot item give me if I go ahead and execute a code over here.

27:09.880 --> 27:13.360
What will students dot items.

27:13.630 --> 27:14.710
Items give me.

27:14.740 --> 27:17.950
It will give me dictionary in the key value pairs.

27:17.950 --> 27:18.220
Right.

27:18.250 --> 27:22.210
Like student one will be one key and this will be a entire value, right?

27:22.240 --> 27:25.150
Inside this this can be a key and this can be a value.

27:25.150 --> 27:27.400
But it will be giving you in this particular format.

27:27.430 --> 27:32.840
Now if I iterate over this nested dictionary this I will consider as my ID, and this will I will consider

27:32.840 --> 27:33.800
as my real value.

27:33.830 --> 27:34.340
Right.

27:34.340 --> 27:38.330
So that is the reason I have written from student underscore ID and student underscore info.

27:38.360 --> 27:38.570
Right.

27:38.600 --> 27:41.120
So this can be a temporary variable right.

27:41.150 --> 27:43.640
Now I will just go ahead and print okay.

27:43.670 --> 27:46.070
So one print I will just use an F string.

27:46.070 --> 27:51.320
And inside this f string let me first of all go ahead and display my student underscore ID okay.

27:51.350 --> 27:56.900
And this will basically be my student underscore info right.

27:57.230 --> 28:04.460
Now I may want a scenario wherein I traverse through or I iterate over all the elements that are inside

28:04.460 --> 28:05.030
this.

28:05.060 --> 28:05.660
Right.

28:05.690 --> 28:06.860
So let me do that.

28:06.860 --> 28:10.760
So I will go ahead and write for key comma value okay.

28:10.970 --> 28:14.330
In student underscore info.

28:14.360 --> 28:16.100
Right I need to iterate through this.

28:16.100 --> 28:19.220
And this is all information are present inside student underscore info.

28:19.250 --> 28:22.820
Now inside this also I will be able to find out keys and values.

28:22.820 --> 28:26.990
So I will go ahead and print F again.

28:27.020 --> 28:28.880
My key.

28:29.010 --> 28:32.430
And this will be nothing, but it will be colon again.

28:32.430 --> 28:35.610
My value right now, let's go ahead and see.

28:35.820 --> 28:42.300
Oh, so there is an error for key comma value in student underscore info dot items.

28:42.300 --> 28:48.690
I missed out dot items because I am not getting too many information out of it, so see how it is printing

28:48.690 --> 28:49.920
this first information.

28:49.920 --> 28:51.180
This is my student.

28:51.180 --> 28:52.710
All the information is over here.

28:52.740 --> 28:56.730
Then I took this info and I iterated through every key and values.

28:56.730 --> 28:57.150
Right?

28:57.150 --> 28:58.590
So name is equal to Chris.

28:58.620 --> 28:59.910
Age is equal to 32.

28:59.940 --> 29:01.680
Then again it went to the for loop.

29:01.680 --> 29:06.090
It found out the another student ID that is student two with this name.

29:06.090 --> 29:08.820
And now it is printing name is equal to Peter and age is equal to five.

29:09.120 --> 29:13.440
So this is how you iterate over nested dictionaries.

29:13.440 --> 29:16.740
And you can play with different different elements as you want okay.

29:17.670 --> 29:22.050
So again any any level of nesting let it be right.

29:22.050 --> 29:23.760
You can iterate through each and everything.

29:23.760 --> 29:27.030
And just by using dot items you can get the key value pairs.

29:27.060 --> 29:27.780
Okay.

29:27.780 --> 29:35.670
Now let me just go ahead and talk about dictionary comprehension.

29:35.670 --> 29:39.240
Like how discussed about nested list comprehension.

29:39.270 --> 29:43.380
Similarly we'll discuss about uh, dictionary comprehension okay.

29:43.890 --> 29:45.480
Now dictionary comprehension.

29:45.480 --> 29:46.710
How does it work.

29:46.740 --> 29:55.620
Uh, and uh, let's say that I want to just print what is the square of a specific number between 1

29:55.620 --> 29:56.220
to 10.

29:56.250 --> 29:56.880
Okay.

29:56.910 --> 30:00.540
So let me just go ahead and create a variable square is equal to.

30:00.600 --> 30:03.960
And again what is the mechanism in list comprehension.

30:03.960 --> 30:05.520
We basically write like this right.

30:05.520 --> 30:10.020
In dictionary comprehension we use uh angular braces right.

30:10.110 --> 30:13.050
So first thing first always remember we need to write.

30:13.050 --> 30:14.100
You can write a for loop.

30:14.100 --> 30:15.630
You can write any condition over here.

30:15.630 --> 30:20.070
So let me go ahead and write for x in range of five okay.

30:20.100 --> 30:25.440
So I'm iterating between 0 to 5 and what I want I want to display something like this x is equal to

30:25.740 --> 30:27.760
x square.

30:27.850 --> 30:28.480
Okay.

30:28.540 --> 30:30.850
I'm basically squaring each and every number.

30:30.850 --> 30:33.040
And that is what is my x value.

30:33.040 --> 30:36.250
And this way it will probably display me.

30:36.250 --> 30:38.920
And this is the way how key and value pairs displays.

30:38.920 --> 30:39.310
Right.

30:39.310 --> 30:40.630
So this is my key.

30:40.630 --> 30:41.980
This will be the value.

30:42.010 --> 30:43.090
This will be my key.

30:43.120 --> 30:45.640
This will be the value as we keep on iterating.

30:45.640 --> 30:52.990
So if I just go ahead and execute this print squares again you can one assignment I definitely like

30:52.990 --> 30:53.380
to give you.

30:53.380 --> 30:57.040
Just go ahead and write this entire thing with a simple for loop okay.

30:57.070 --> 31:01.390
And then you try to convert this into a dictionary right a dictionary comprehension.

31:01.390 --> 31:04.090
So here you can see now I'm able to get a key value pair.

31:04.090 --> 31:05.320
So this is my zero is my key.

31:05.350 --> 31:06.220
Zero is the value.

31:06.250 --> 31:09.220
One is the key one is the value two is the key, four is the value.

31:09.220 --> 31:11.410
And we are doing the squaring of it right.

31:11.440 --> 31:13.150
Squaring off each and every number.

31:14.140 --> 31:20.350
Now let's say I want to probably go ahead and just find out the squares of only even number.

31:20.350 --> 31:22.960
So here I will also show you by writing conditions.

31:22.960 --> 31:25.450
So let me just go ahead and write conditional.

31:26.060 --> 31:27.080
dictionary.

31:29.510 --> 31:31.430
Comprehension.

31:32.420 --> 31:33.110
Okay.

31:33.410 --> 31:34.880
Comprehension.

31:35.870 --> 31:41.360
Now, the best way over here is that I will go ahead and create even variable.

31:41.420 --> 31:48.950
Now first of all for x in range of ten let me just go ahead and take ten variables.

31:48.980 --> 31:53.810
Okay I know what I need to display x square okay.

31:53.810 --> 31:55.880
But I will write one more condition.

31:55.880 --> 32:04.100
If if x modulus two is double equal to zero I will go ahead and print my events.

32:04.130 --> 32:04.790
Okay.

32:04.940 --> 32:06.620
Now let me just go ahead and execute it.

32:06.620 --> 32:13.610
So this is zero column 0244 column 16 636 864.

32:13.640 --> 32:14.000
Right.

32:14.030 --> 32:18.200
So this is in short giving me the square of only even numbers.

32:18.230 --> 32:18.920
Right.

32:19.100 --> 32:22.460
Now these are some of the examples.

32:22.490 --> 32:23.840
Again dictionary comprehension.

32:23.840 --> 32:26.640
You can like how do you execute with respect to list?

32:26.670 --> 32:30.300
Similarly, you can also do it with respect to, uh, deaneries.

32:30.330 --> 32:35.670
Only thing is that you need to have the output over here in the form of key value pairs.

32:35.700 --> 32:36.240
Okay.

32:36.360 --> 32:38.880
So this was one of the most amazing thing.

32:38.910 --> 32:39.450
Okay.

32:39.480 --> 32:46.620
Let me just show you some of the practical examples that may be beneficial for understanding, um,

32:46.620 --> 32:48.420
some more practical examples.

32:48.420 --> 32:54.660
And in the next video I will also talk about some of the amazing use cases where all this list, dictionaries

32:54.660 --> 32:55.950
or dictionaries will be used.

32:55.950 --> 32:56.340
Okay.

32:56.370 --> 32:58.200
So practical examples.

32:58.560 --> 32:59.070
Okay.

32:59.220 --> 33:04.500
Now with respect to this practical example I will give you a task.

33:04.890 --> 33:08.760
Use a dictionary okay.

33:09.150 --> 33:19.020
Use a dictionary to count the frequency of elements in list okay.

33:19.350 --> 33:21.000
Now we'll go ahead and see this.

33:21.000 --> 33:23.460
Let's say I have numbers.

33:23.530 --> 33:30.670
Numbers is nothing, but it is in the list format one comma, two comma, two comma, three comma,

33:30.670 --> 33:36.190
three comma, three comma four comma four comma four comma four.

33:36.220 --> 33:37.750
Okay, so these are my numbers.

33:37.780 --> 33:42.790
Now you need to write a code using dictionary to count the frequency of every element in the list,

33:42.790 --> 33:46.900
like one is present one time, two is present two times something like this.

33:46.900 --> 33:48.610
So I will go ahead and create.

33:48.610 --> 33:50.500
First of all you try it out, okay.

33:50.920 --> 33:56.500
Just pause for five, five, at least five minutes and just try to write whatever is possible by you

33:56.500 --> 33:58.390
and then go ahead and see the solution.

33:58.420 --> 33:58.960
Okay.

33:58.990 --> 34:02.410
Now let me just go ahead and create a frequency empty variable.

34:02.440 --> 34:08.320
Then I will go ahead and write for number in numbers.

34:08.470 --> 34:09.130
Okay.

34:09.700 --> 34:12.460
First of all I will iterate through each and every number.

34:12.490 --> 34:17.380
Then I will go ahead and write if number in frequency okay.

34:17.410 --> 34:21.010
If the number is basically present in the frequency then it is fine.

34:21.070 --> 34:28.190
Then what we do, we basically take that frequency of number and we keep on incrementing it.

34:28.220 --> 34:28.490
Right.

34:28.520 --> 34:29.990
Plus is equal to one.

34:30.260 --> 34:35.810
Now what exactly this is basically doing this is with respect to the key and with respect to that particular

34:35.810 --> 34:39.710
key I need to just increment keep on incrementing the value saying that hey it is present one time,

34:39.710 --> 34:40.580
two time, three time.

34:40.580 --> 34:42.920
Like when when two times basically comes.

34:42.920 --> 34:43.190
Right.

34:43.190 --> 34:47.060
So first time it will be zero and then it will go to one, two, three like that okay.

34:47.180 --> 34:55.640
Else if it is coming for the first time then we should basically assign that value to one, right.

34:56.090 --> 34:57.680
Otherwise it will keep on incrementing.

34:57.680 --> 34:59.330
So number is equal to one.

34:59.540 --> 35:02.210
Now let me just go ahead and print the frequency.

35:02.210 --> 35:07.250
So here you will be able to understand how many number of times one is present two is present and three

35:07.280 --> 35:07.670
is present.

35:07.670 --> 35:08.780
Just see this code.

35:08.780 --> 35:10.310
Observe this code okay.

35:10.340 --> 35:13.670
If I go ahead and execute it now here you can see numbers.

35:13.670 --> 35:14.630
It is iterating.

35:14.630 --> 35:16.940
If number is in the frequency initially it is not present.

35:16.940 --> 35:18.530
So what it will do it will go over here.

35:18.560 --> 35:21.050
Take this number and it will assign the value one.

35:21.120 --> 35:23.850
then it will go again back to the next number.

35:23.880 --> 35:24.990
Two is present.

35:25.020 --> 35:26.850
Number is not present in the frequency.

35:26.880 --> 35:29.610
It will again go back to the else loop and again it will update one.

35:29.640 --> 35:32.010
Then again it will go back okay.

35:32.040 --> 35:33.420
Then the next number is two.

35:33.450 --> 35:35.400
This time it is present in the frequency.

35:35.400 --> 35:36.360
So it will go inside.

35:36.360 --> 35:41.070
This frequency of two is equal to plus is equal to one right plus equal to one.

35:41.070 --> 35:43.770
So that basically means we are just going to increment one with one.

35:43.770 --> 35:44.760
So it will become two.

35:44.790 --> 35:46.560
So how many number of times two is present.

35:46.560 --> 35:48.330
Only that much will be remaining three.

35:48.360 --> 35:49.890
It will increment till three four.

35:49.920 --> 35:52.980
It will increment till four because there are four number of fours okay.

35:53.010 --> 35:56.820
So this is how you specifically get one amazing thing okay.

35:57.000 --> 36:00.360
Now let me just show you another one example.

36:00.360 --> 36:02.340
And this is probably we have not discussed.

36:02.340 --> 36:06.900
Also let's go ahead and merge two dictionaries into one okay.

36:06.930 --> 36:11.370
There may be scenario that I may have two dictionaries and I really want to merge them into one okay.

36:11.400 --> 36:15.000
This is one kind of hack that I really want to show it to you.

36:15.000 --> 36:20.890
So dictionary one and this is what we will understand when we understand about functions because there

36:20.890 --> 36:25.360
is one very key important parameter which is called as positional argument and keyword argument.

36:25.390 --> 36:25.930
Okay.

36:26.410 --> 36:29.710
Uh, why we use Asterix mask and all?

36:29.710 --> 36:31.900
I'll just discuss when we discuss about the function.

36:31.930 --> 36:36.910
So now let me say that hey there is my dictionary elements over here a is equal to one.

36:36.940 --> 36:40.060
And this B is nothing but equal to two okay.

36:40.090 --> 36:42.730
Similarly I may have a different dictionary.

36:42.730 --> 36:53.290
The second dictionary here b colon three and c is colon four.

36:54.310 --> 36:54.850
Okay.

36:54.880 --> 37:01.930
Now if I go ahead and write merge dictionary okay.

37:02.110 --> 37:09.760
Now see if I go ahead and try to merge this dictionary I will use two amazing things over here.

37:09.760 --> 37:11.710
One is asterisk.

37:11.740 --> 37:17.500
Asterisk dictionary one okay comma asterisk asterisk dictionary two.

37:17.860 --> 37:24.440
Now the best thing about this, Asterix, is that any number of a number of key value pairs.

37:24.470 --> 37:24.860
Right?

37:24.890 --> 37:30.200
If I'm giving two double asterisks, any number of key value pairs, that is probably going to come.

37:30.200 --> 37:34.460
It is just going to take that as a key value pair, and it is just going to append it inside this particular

37:34.460 --> 37:35.540
dictionary okay.

37:36.170 --> 37:38.420
This is basically called as a keyword argument.

37:38.450 --> 37:38.870
Okay.

37:38.900 --> 37:41.330
And over here you can see in dictionary one and dictionary two.

37:41.360 --> 37:42.770
Both are keyword argument.

37:42.800 --> 37:42.980
Okay.

37:43.010 --> 37:47.870
So keyword argument basically means any value that is present in the form of key value pairs.

37:47.900 --> 37:48.380
Okay.

37:48.410 --> 37:53.210
Now if I go ahead and print this merge dictionary and we'll discuss more about that in functions.

37:53.240 --> 37:53.780
Okay.

37:53.960 --> 37:57.200
So here you can see that it has merged very much easily.

37:57.230 --> 37:57.830
Okay.

37:58.130 --> 38:01.940
So I hope you got an idea about dictionaries.

38:02.090 --> 38:06.650
We have discussed so many different lines of code I've written over here in front of you, and almost

38:06.650 --> 38:08.660
each and every topics with some examples.

38:08.660 --> 38:13.700
And all I've actually explained, explained in a way that you should be able to understand a very lame

38:13.700 --> 38:14.420
language.

38:14.420 --> 38:16.070
So I hope you like this particular video.

38:16.100 --> 38:17.060
This was it from my side.

38:17.060 --> 38:18.110
I will see you in the next video.

38:18.110 --> 38:18.500
Thank you.

38:18.530 --> 38:18.980
Take care.
