A few other methods of the list which can be you're going to have a few thoughts at the list which are
enlistee dot.
You know you can have you can have a look at all the methods you can insert.
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
to insert a value called 15.
OK and then if I print the LSD what happens.
Control shift left 10.
So here at add index to 0 1 2 and 15 has been inserted right LSD dot LSD that you have.
You can do a pop where papa is removing pop removes pop removes the last element by default.
Correct.
So I just saved Scott because out OK could torture 10.
So can you see the last element has been popped out.
When you do a pop if you want to pop out from a particular index let's say for example I want to pop
out from capitis.
Correct.
I want to pop out from here.
OK so this is minus one.
See this is in next year.
This is one this is two.
This is three.
This is four.
This is five to one.
And so one then I can say these are these are index minus one minus two.
This entire thing is minus three minus four minus five to one.
So if I say LSD or pop I want to pop out minus three so minus three is that entire list.
And now if I print the list the entire list has been popped out and you can.
As you can see the list is just this much right.
You can use some built in functions also.
I can use print some awfullest right.
It will print all the some of the elements in this particular list that's going to be 53 and you're
going to have you can have Prynne.
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
10.
See this was the original list.
But after doing a sort it sorted them in the right order.
If you if you say LSD dot reverse right if you CLEC that reverse and then if you print the LSD you're
again going to have Murugan going to have as you can see so it's going to be sorted in descending order.
All right so this is about a list.
OK so if I go on to something like the NextEra structure tuples is dictionaries dictionaries insets.
So we just got to cover all of them quickly in about two three minutes so that you know you get the
base for the entire foot for the father things that we are going to go.
OK one important thing about list I forgot.
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
to say what list list does.
There's something there's a concept about list called list comprehension.
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
here.
I'm going to come in all of them and I'm going to do is I'm going to say all right.
So I'm going to create another list.
Let me call the rescue list.
So I create another list.
Now there is a concept of miscomprehension where rescue list is a new list where for every element in
your list LSD for every element is so Escuela will contain a school list will contain for every element
in the list the school list contains something that expression is expected here.
All right.
So what does it contain.
Let's say it contains the element Square.
So if I print LSD LSD and if I printed Eskew can you see the list is this and this is containing it
for each element of LSD SU Lister's containing A-squared of them.
Now this particular concept where you have a list and then you create a new list which is a square of
each of this list x square of each of the elements of the list you create a new list in such a way.
This particular concept diskless list comprehension.
We had seen that before and we just recap it because we're going to use it extensively when we you know
when we think about umpire let's say for example you know if I take up if I take a temperature if I
take a temperature I have temperatures in Celsius.
All right if I'll have a list of temperatures in Celcius.
So it's going to be like 20 22 23 24.
25.
Come on.
Twenty five point six point twenty six point seven and so on and then it comes back to 25.
And you know it varies.
So there's a temperature in Celsius if you want to come if you want to compute the temperature in Fahrenheit
if you want to compute the temperature and Fahrenheit so I need to create a new list which is going
to be for every element in temperature.
I need to do something like this for every element in temperature I need to have an F in f a new you
know the value corresponding to each temperature value in degree in degrees I need to have a certain
height value where that's going to be element multiplied by nine divided by five plus thirty two right.
Multiplied by nine.
And if I now print instead of printing a list I'll just going to print temp and print f Surfcontrol
shift f 10 turn right so you're I have the temperature in Celsius and here I have the temperature in
degrees Fahrenheit.
Right.
So this is where a list comprehension is used of course when we use data and analysis libraries we are
going to understand all this.
There's going to be cropped out from there.
OK so temperatures can be taken from different temperature sensors in Iowa where temperatures are going
to be stored in let's say Celcius.
We might have to do conversions like these where we need to make use of for make use of certain libraries.
All right.
There's about there's about list.
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
say Nuts Bolts not bolts too.
OK.
So here I'm going to just we're going to go quickly to topples Stupples or defined with round brackets
right.
Again something like this 5 come to something like this right.
Couples The greatest advantage about couples.
You can access them like this you can print what is t of zero but you cannot change t of C or you cannot
change the value could do that in the list.
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
to also a printer.
So it prints 0 that's 5.
But then it gives you an error for this it says tuple object does not support item assignment you can
do this.
You can change the value in a couple of cause Stupples have not much mattered if you remember topples
did not count.
It can just be those two methods only count an index.
It gives you the index of a particular value.
Let's say if you say a 4.
It will say four exist at three index 3 0 1 2 3 and that's right.
It gives you the first Ockrent of the particular element.
OK so that's about a topple which we're not going to care much about it.
And then we have another we have another one.
If I create a new pite in file and if I say not spalls
right and let's say a set.
If I define a set with multiple values something like this.
If you remember right and if I print this out OK controlled shift as 10 as you can see OK a set.
Oh sorry there's a list set.
A set is defined with curly brackets.
Right.
Control chips in as you can see what happened.
Not all elements are there all elements which are repeated are not repeated anymore.
Right.
Only one occurrence of every unique element is there.
There is no repetition 5 is repeated 1 2 3 3 times.
But here there's only one 5 right.
And if you can see that the order of S S is you cannot access sets without their index right.
You cannot say as of zero Why.
Because sex object does not support that's indexing it is completely unordered so you cannot use this
but sets are used generally.
When are they going to be used they're going to be used whenever you want to find out.
Unions and intersections and stuff like that and you want to find out if there are unique elements in
a particular list or something like that we can use it.
OK so that's not about sets.
Nothing much new out there let's go for a new pipe and find and let's see what is there in a dictionary.
So again nuts bolts.
So a dictionary is again defines brackets.
But this time this time you have something like keys.
So you're going to have a key and a value let's say for example Number 25 is Roy and Columbo.
Roll number 50 is you know is going to be is going to be a new or something like that.
Right.
And you're going to have 80 is going to be Rahil sorry you're going to have three in.
OK.
So you to have different.
So you're as you can see a dictionary the main good part about dictionary is you can have your own custom
index which means you don't need to have 0 1 2.
You can access it with the key that is 25 custom index.
So of course I didn't print this out so if you don't print that you cannot see it.
So print d of 25 that's Roy.
So that's a body dictionary that's about you.
Well that's what the data structures which are that in Python.
Now if you want to create your own data structure you need to create a class and we need to create an
object.
But we will see in the next lesson very quickly we saw that already but we just going to recap it very
soon.
All right let's go.