WEBVTT

00:01.170 --> 00:03.780
Let's solve the next set of questions.

00:04.050 --> 00:13.080
So the first question is a set one by adding the items from set to accept the common items.

00:13.770 --> 00:22.580
So we want to update this set one with adding values which are not already present in segment.

00:22.600 --> 00:26.670
That is, we want to add the value 60 and 72.

00:27.480 --> 00:31.050
You can use any function, anything any more than you will.

00:32.640 --> 00:37.590
Next question is rhenium key city to location in the following dictionary?

00:37.980 --> 00:42.660
So in sort of city, we want to change this particular key to location.

00:44.130 --> 00:49.650
The third questions change Brad salary to eighty five on from given by conditioning's.

00:49.680 --> 00:56.040
So this is a python dictionary where we have different employees and for each employee we have the name

00:56.040 --> 00:56.850
and the salary.

00:57.180 --> 01:04.380
So we just want to update the salary of the person Gragg to eighty five hundred instead of sixty five

01:04.380 --> 01:04.740
hundred.

01:05.220 --> 01:12.270
So you can thornes, though, we do try to solve these questions and then we will go through the solutions

01:12.270 --> 01:13.020
one by one.

01:22.260 --> 01:25.590
So let's go ahead and solve the first question.

01:26.760 --> 01:38.160
So here we have set one and set to to simply find out the values which are present in set one and not

01:38.160 --> 01:39.900
present in said two.

01:40.260 --> 01:42.660
We can find out the symmetric difference.

01:42.900 --> 01:45.720
So let's find out the symmetric difference first.

01:46.530 --> 01:50.140
So let's set one down.

01:51.210 --> 01:51.630
Then it

01:58.860 --> 02:01.290
said, let's see what it is.

02:01.680 --> 02:06.210
So it gives me then 20, 60, 70.

02:06.510 --> 02:10.650
So you can see the values 30, 40 and 50 are common between this.

02:10.890 --> 02:15.570
So we are just getting the values 10, 20, 30 and 60, 70 out of it.

02:15.990 --> 02:20.820
Now, if I want to update this particular thing to the set one,

02:23.760 --> 02:28.560
we can simply say don't update.

02:32.010 --> 02:36.510
So this will simply update the values to secure.

02:37.410 --> 02:38.880
So let's print that one.

02:43.050 --> 02:46.530
So here you can see we have the values in simple.

02:47.040 --> 02:51.420
Instead of updating, you could have also done it this way.

02:51.420 --> 02:55.370
Simply find out the symmetric difference and a sign that does it.

02:56.910 --> 02:58.470
You can follow any method.

02:59.190 --> 03:05.790
Submitting the Prince update is an emplace operator, so it will updated then and then you won't need

03:05.790 --> 03:06.870
to reassign it.

03:09.270 --> 03:14.790
The next problem is to rename the key city to location.

03:17.670 --> 03:21.870
So for this, we can simply apply a simple method.

03:21.870 --> 03:25.850
We can simply create a new key in this particular dictionary.

03:25.860 --> 03:26.820
So how do we do that?

03:26.820 --> 03:27.840
We see a sample

03:31.350 --> 03:38.970
and we create a new key that this location and is inside this.

03:38.970 --> 03:42.060
We want to put in the value which is present in Sydney.

03:42.750 --> 03:48.990
So how do we get the value, present density and simultaneously drop this also?

03:49.260 --> 03:57.120
So what you would have done is you could have removed this key itself and then created a new key and

03:57.120 --> 03:58.050
added the value.

03:58.290 --> 04:03.510
Or you can do both operations simultaneously using the WAP operation.

04:03.720 --> 04:08.810
So we can simply assign some value sample.

04:10.110 --> 04:19.080
They thought up and inside this we give the city.

04:19.440 --> 04:27.750
So what happens is we are able to form the value city from the key value per city, and then we are

04:27.750 --> 04:29.510
copying this key from here.

04:29.520 --> 04:34.680
We what has a property of returning the value to us.

04:34.860 --> 04:39.510
So when we return used a pop operation, it will return the value.

04:39.510 --> 04:44.610
And simultaneously, when we are assigning it to the new key, which we are trying to create, which

04:44.610 --> 04:51.330
is location, it is simply adding the globe, the value to this particular key.

04:51.630 --> 04:55.620
And hence, when we print the sample in the queue,

05:00.030 --> 05:02.370
we get the updated value of location.

05:03.810 --> 05:07.110
So you can use this pop operation in this particular month.

05:07.590 --> 05:09.960
And there could have been other solutions also.

05:10.140 --> 05:11.670
You can try any of those.

05:13.650 --> 05:20.490
Next is where we want to simply update the salary of Bragg.

05:21.030 --> 05:28.650
Now, notice here that this is a dictionary and this dictionary has multiple keys.

05:28.950 --> 05:32.670
These multiple keys are in one and two and three.

05:34.380 --> 05:39.360
And each amp has another dictionary as its value.

05:39.570 --> 05:43.680
So let's try to retrieve the value first and then we try to update it.

05:44.070 --> 05:45.780
So let's give these of the.

05:48.690 --> 05:53.900
And we want to get the value of Bragg, which is under three.

05:53.910 --> 05:55.170
So let's get three.

05:59.220 --> 06:00.030
Let's run this.

06:00.540 --> 06:03.330
So we get named Bragg salary.

06:03.480 --> 06:04.590
Sixty five hundred.

06:05.670 --> 06:12.810
Now, inside this further, what I want to do is I want to I don't want to get the name, but I want

06:12.810 --> 06:13.830
to get the salary.

06:14.370 --> 06:17.640
So let's go for that and get the salary of this person.

06:19.890 --> 06:21.110
When we run this, we get to.

06:21.290 --> 06:27.290
Five hundred now you can simply assign the value what you want, those nine to fifty five hundred.

06:28.160 --> 06:35.600
And now when you run these numbers, you can see the value has been updated.

06:37.340 --> 06:45.930
So you can use this method to reassign the values or you can also see what the values are, and I truly

06:46.020 --> 06:51.290
believe you can go inside different data structures to access a particular value also.

06:54.470 --> 06:55.940
That's it for this one.

06:56.180 --> 07:03.440
You have a lot more similar problems present in the practice sessions, which until practice questions

07:03.440 --> 07:05.900
which are present at the end of the module as well.

07:06.320 --> 07:08.180
So you can refer to those also.

07:08.840 --> 07:09.350
Thank you.
