WEBVTT

00:00.850 --> 00:05.800
A few other methods of the list which can be you're going to have a few thoughts at the list which are

00:05.830 --> 00:07.610
enlistee dot.

00:07.850 --> 00:12.280
You know you can have you can have a look at all the methods you can insert.

00:12.370 --> 00:18.340
Let's see if I insert add a particular index I need to say the next let's say add in next to I want

00:18.340 --> 00:20.450
to insert a value called 15.

00:20.620 --> 00:23.860
OK and then if I print the LSD what happens.

00:23.860 --> 00:25.320
Control shift left 10.

00:25.390 --> 00:36.520
So here at add index to 0 1 2 and 15 has been inserted right LSD dot LSD that you have.

00:36.820 --> 00:45.170
You can do a pop where papa is removing pop removes pop removes the last element by default.

00:45.370 --> 00:45.670
Correct.

00:45.670 --> 00:50.400
So I just saved Scott because out OK could torture 10.

00:50.550 --> 00:53.010
So can you see the last element has been popped out.

00:53.140 --> 00:59.440
When you do a pop if you want to pop out from a particular index let's say for example I want to pop

00:59.440 --> 01:01.940
out from capitis.

01:02.130 --> 01:02.480
Correct.

01:02.500 --> 01:04.410
I want to pop out from here.

01:04.410 --> 01:06.100
OK so this is minus one.

01:06.100 --> 01:07.440
See this is in next year.

01:07.450 --> 01:09.070
This is one this is two.

01:09.250 --> 01:09.910
This is three.

01:09.910 --> 01:10.720
This is four.

01:10.720 --> 01:12.570
This is five to one.

01:12.670 --> 01:20.600
And so one then I can say these are these are index minus one minus two.

01:20.650 --> 01:25.000
This entire thing is minus three minus four minus five to one.

01:25.000 --> 01:34.260
So if I say LSD or pop I want to pop out minus three so minus three is that entire list.

01:34.360 --> 01:40.990
And now if I print the list the entire list has been popped out and you can.

01:41.140 --> 01:45.160
As you can see the list is just this much right.

01:45.310 --> 01:47.590
You can use some built in functions also.

01:47.690 --> 01:52.000
I can use print some awfullest right.

01:52.020 --> 01:58.040
It will print all the some of the elements in this particular list that's going to be 53 and you're

01:58.040 --> 02:01.460
going to have you can have Prynne.

02:02.120 --> 02:13.150
So if I have LSD got LSD that's sort right sort and if I printed LSD as you can see it all chipped f

02:13.150 --> 02:13.540
10.

02:13.540 --> 02:14.830
See this was the original list.

02:14.840 --> 02:19.140
But after doing a sort it sorted them in the right order.

02:19.610 --> 02:26.620
If you if you say LSD dot reverse right if you CLEC that reverse and then if you print the LSD you're

02:26.630 --> 02:33.170
again going to have Murugan going to have as you can see so it's going to be sorted in descending order.

02:33.190 --> 02:35.260
All right so this is about a list.

02:35.450 --> 02:41.200
OK so if I go on to something like the NextEra structure tuples is dictionaries dictionaries insets.

02:41.240 --> 02:46.520
So we just got to cover all of them quickly in about two three minutes so that you know you get the

02:46.520 --> 02:52.760
base for the entire foot for the father things that we are going to go.

02:52.880 --> 02:55.440
OK one important thing about list I forgot.

02:55.820 --> 03:03.420
We need to all this one thing that we will use it when we when we say when we use NUMP by we are going

03:03.420 --> 03:05.500
to say what list list does.

03:05.490 --> 03:09.950
There's something there's a concept about list called list comprehension.

03:09.960 --> 03:14.610
So what I'm going to do is I'm going to commend all of these which are there and my which are they're

03:14.700 --> 03:15.420
here.

03:15.570 --> 03:20.350
I'm going to come in all of them and I'm going to do is I'm going to say all right.

03:20.520 --> 03:23.070
So I'm going to create another list.

03:23.100 --> 03:24.910
Let me call the rescue list.

03:25.020 --> 03:26.450
So I create another list.

03:26.570 --> 03:36.420
Now there is a concept of miscomprehension where rescue list is a new list where for every element in

03:37.040 --> 03:45.360
your list LSD for every element is so Escuela will contain a school list will contain for every element

03:45.360 --> 03:51.530
in the list the school list contains something that expression is expected here.

03:51.630 --> 03:52.150
All right.

03:52.320 --> 03:53.760
So what does it contain.

03:53.760 --> 03:56.440
Let's say it contains the element Square.

03:56.640 --> 04:07.880
So if I print LSD LSD and if I printed Eskew can you see the list is this and this is containing it

04:07.890 --> 04:12.770
for each element of LSD SU Lister's containing A-squared of them.

04:13.050 --> 04:23.150
Now this particular concept where you have a list and then you create a new list which is a square of

04:23.150 --> 04:28.230
each of this list x square of each of the elements of the list you create a new list in such a way.

04:28.230 --> 04:30.620
This particular concept diskless list comprehension.

04:30.630 --> 04:39.180
We had seen that before and we just recap it because we're going to use it extensively when we you know

04:39.180 --> 04:46.500
when we think about umpire let's say for example you know if I take up if I take a temperature if I

04:46.500 --> 04:49.500
take a temperature I have temperatures in Celsius.

04:49.500 --> 04:53.090
All right if I'll have a list of temperatures in Celcius.

04:53.250 --> 04:58.680
So it's going to be like 20 22 23 24.

05:00.150 --> 05:00.710
25.

05:00.720 --> 05:01.120
Come on.

05:01.140 --> 05:09.150
Twenty five point six point twenty six point seven and so on and then it comes back to 25.

05:09.170 --> 05:11.150
And you know it varies.

05:11.580 --> 05:17.660
So there's a temperature in Celsius if you want to come if you want to compute the temperature in Fahrenheit

05:17.790 --> 05:22.920
if you want to compute the temperature and Fahrenheit so I need to create a new list which is going

05:22.920 --> 05:26.760
to be for every element in temperature.

05:27.030 --> 05:33.960
I need to do something like this for every element in temperature I need to have an F in f a new you

05:33.960 --> 05:38.870
know the value corresponding to each temperature value in degree in degrees I need to have a certain

05:38.910 --> 05:48.900
height value where that's going to be element multiplied by nine divided by five plus thirty two right.

05:48.900 --> 05:50.070
Multiplied by nine.

05:50.070 --> 05:57.870
And if I now print instead of printing a list I'll just going to print temp and print f Surfcontrol

05:58.050 --> 06:03.960
shift f 10 turn right so you're I have the temperature in Celsius and here I have the temperature in

06:03.960 --> 06:05.050
degrees Fahrenheit.

06:05.100 --> 06:05.670
Right.

06:05.700 --> 06:12.920
So this is where a list comprehension is used of course when we use data and analysis libraries we are

06:12.920 --> 06:14.510
going to understand all this.

06:14.640 --> 06:16.730
There's going to be cropped out from there.

06:17.010 --> 06:23.190
OK so temperatures can be taken from different temperature sensors in Iowa where temperatures are going

06:23.190 --> 06:24.920
to be stored in let's say Celcius.

06:24.930 --> 06:32.160
We might have to do conversions like these where we need to make use of for make use of certain libraries.

06:32.160 --> 06:33.110
All right.

06:33.280 --> 06:35.140
There's about there's about list.

06:35.220 --> 06:41.220
What I'm going to do is there's about list and I'm going to create a new Python file and I'm going to

06:41.220 --> 06:47.740
say Nuts Bolts not bolts too.

06:48.290 --> 06:48.720
OK.

06:48.750 --> 06:54.090
So here I'm going to just we're going to go quickly to topples Stupples or defined with round brackets

06:54.090 --> 06:55.320
right.

06:55.380 --> 07:00.570
Again something like this 5 come to something like this right.

07:00.660 --> 07:03.250
Couples The greatest advantage about couples.

07:03.270 --> 07:13.550
You can access them like this you can print what is t of zero but you cannot change t of C or you cannot

07:13.560 --> 07:15.200
change the value could do that in the list.

07:15.210 --> 07:22.550
But can I do this in in a couple it's going to throw you an error it's going to say it's not subscribe

07:22.550 --> 07:24.130
to also a printer.

07:24.560 --> 07:27.670
So it prints 0 that's 5.

07:27.710 --> 07:32.390
But then it gives you an error for this it says tuple object does not support item assignment you can

07:32.390 --> 07:33.370
do this.

07:33.470 --> 07:41.060
You can change the value in a couple of cause Stupples have not much mattered if you remember topples

07:41.090 --> 07:43.020
did not count.

07:43.040 --> 07:46.130
It can just be those two methods only count an index.

07:46.280 --> 07:48.890
It gives you the index of a particular value.

07:48.890 --> 07:50.950
Let's say if you say a 4.

07:51.200 --> 07:57.270
It will say four exist at three index 3 0 1 2 3 and that's right.

07:57.470 --> 08:01.340
It gives you the first Ockrent of the particular element.

08:01.400 --> 08:05.800
OK so that's about a topple which we're not going to care much about it.

08:05.810 --> 08:10.130
And then we have another we have another one.

08:10.280 --> 08:15.110
If I create a new pite in file and if I say not spalls

08:18.980 --> 08:22.310
right and let's say a set.

08:22.460 --> 08:26.240
If I define a set with multiple values something like this.

08:26.270 --> 08:35.840
If you remember right and if I print this out OK controlled shift as 10 as you can see OK a set.

08:35.840 --> 08:38.420
Oh sorry there's a list set.

08:38.630 --> 08:41.250
A set is defined with curly brackets.

08:42.480 --> 08:43.220
Right.

08:43.320 --> 08:46.770
Control chips in as you can see what happened.

08:47.100 --> 08:52.320
Not all elements are there all elements which are repeated are not repeated anymore.

08:52.470 --> 08:52.830
Right.

08:52.830 --> 08:55.950
Only one occurrence of every unique element is there.

08:56.100 --> 09:00.410
There is no repetition 5 is repeated 1 2 3 3 times.

09:00.420 --> 09:02.240
But here there's only one 5 right.

09:02.490 --> 09:09.360
And if you can see that the order of S S is you cannot access sets without their index right.

09:09.360 --> 09:11.390
You cannot say as of zero Why.

09:11.470 --> 09:17.410
Because sex object does not support that's indexing it is completely unordered so you cannot use this

09:17.700 --> 09:19.560
but sets are used generally.

09:19.560 --> 09:22.770
When are they going to be used they're going to be used whenever you want to find out.

09:22.770 --> 09:29.310
Unions and intersections and stuff like that and you want to find out if there are unique elements in

09:29.550 --> 09:32.700
a particular list or something like that we can use it.

09:33.060 --> 09:36.120
OK so that's not about sets.

09:36.240 --> 09:43.080
Nothing much new out there let's go for a new pipe and find and let's see what is there in a dictionary.

09:43.080 --> 09:45.140
So again nuts bolts.

09:45.150 --> 09:47.090
So a dictionary is again defines brackets.

09:47.100 --> 09:52.830
But this time this time you have something like keys.

09:53.070 --> 10:02.090
So you're going to have a key and a value let's say for example Number 25 is Roy and Columbo.

10:03.000 --> 10:11.800
Roll number 50 is you know is going to be is going to be a new or something like that.

10:11.900 --> 10:12.420
Right.

10:12.590 --> 10:22.400
And you're going to have 80 is going to be Rahil sorry you're going to have three in.

10:22.810 --> 10:23.220
OK.

10:23.390 --> 10:25.450
So you to have different.

10:25.460 --> 10:31.610
So you're as you can see a dictionary the main good part about dictionary is you can have your own custom

10:31.610 --> 10:34.480
index which means you don't need to have 0 1 2.

10:34.490 --> 10:38.870
You can access it with the key that is 25 custom index.

10:38.870 --> 10:42.960
So of course I didn't print this out so if you don't print that you cannot see it.

10:43.190 --> 10:48.690
So print d of 25 that's Roy.

10:48.730 --> 10:52.810
So that's a body dictionary that's about you.

10:52.890 --> 10:55.250
Well that's what the data structures which are that in Python.

10:55.510 --> 10:59.020
Now if you want to create your own data structure you need to create a class and we need to create an

10:59.020 --> 11:00.010
object.

11:00.310 --> 11:05.230
But we will see in the next lesson very quickly we saw that already but we just going to recap it very

11:05.230 --> 11:05.810
soon.

11:06.160 --> 11:07.150
All right let's go.
