And then let's talk about some of the data structures that are very, very useful in Python, and you
definitely need to know them.
So the first one I want to cover is the list or the lists.
So lists usually is just the list of items.
It doesn't matter if they are numbers or strings.
And so it is a good practice to have a similar types of items in your list.
So let's create a list of famous or famous tech companies.
So let's write a check list.
And this will be equal to Brackett's, Apple, Microsoft, Samsung.
Dell and HP.
So let's see what we can do basically with this latest outage for some operations here.
So first of all, I would like let's print some of the components inside this list, some of the elements.
So let's write the print checklist.
And then I would like to print the elements from zero until two.
OK, so obviously zero is apple and trees here, but on some.
But since we say until two, we print only the first two items.
OK, zero one and we'll stop at two.
This is how Python works.
This is the logic behind it.
So if I run the code, you will see that we print Apple and Microsoft.
Now, you can also change the elements inside the list by simply writing a checklist, the zero.
So the position of the element you want to change.
And here I write this one so you can see that when we print the.
Checklist, we should get some changes, some quite significant changes, and you can set up Apple was
changed to test one in our list, then we can do some quite cool operations inside our list.
Let's see, we want to write a list and we want to remove some of the values there.
So let's remove in the vault.
I want to remove is Samsung.
OK?
So if I print.
Then the list I should see that the Samsung has been removed from our list.
Now let's see some other operations.
Let's see what will happen if we would like to insert certain or certain elements.
So let's right here, insert them here.
You need to specify two things.
The index where we want to insert the object.
So you have a presence in the industry.
And let's say I would like the object to be this one.
So this means this will be added to a third position.
And you can see that now on the third position where it was.
Now it's this one and the NHP, they're shifted towards the right side of our list.
OK, that's it here.
And then let's investigate some more operations that you can do.
So you can actually check the length of the string by doing plain and simple, write the name of the
list in here.
You should get printed the length of our string.
So as you can see, our string have five elements and for that reason, its latest five.
You can also get some quite interesting objects for your list.
Let's say we want to check if Microsoft is on our list.
So I will simply write Microsoft.
In.
They placed so here we are checking if Microsoft is syndicalist and obviously the results here will
be a boolean variable and you can see that we get the results through because Microsoft.
Is that our list?
If I were to write this one now.
You are going to see that will get false because we don't have this when our list.
That's it, pretty simple stuff.
Now, finally, if you would like to clear the list, so I will just leave it here to print it, you
can simply write.
The name of the list which the list and then clear.
And now you can see if I tried to print that, I will basically get nothing.
So when you get this break is here, this means that your list is now, guys.
I also want to cover one other topic, which is quite interesting.
And this is a very nice data structure that is very useful when you are developing quotes in Python.
So this is called dictionary and the dictionary usually have a name of an item and assign value to the
title.
I will show you how it's done.
For example, let's say you want to work in a supermarket and you have certain fruits there with price
to each fruit.
So let's write fruits equals and here's how we declare a dictionary.
So the first item will be.
Banana and banana will be equal to the zero point.
49.
Then we're on our list, what orange, what will be equal to one point five for its price will be 150
dollars, let's say then at.
Ethanol, which will be equal to one point all nine or one point all.
So basically this is our dictionary and let's see what else you can do with the dictionary.
So if I write.
Fruits and banana, I can make its price different so I can make the quota to six to eight.
So your footprint, the fruits after that, you see that the price will change.
So you can see that now the price of the banana is different.
It is to six.
Now, you can also just print the price of certain elements with the right fruits orange.
This means that the masking for the price of the orange in the price of the orange is one fifty.
And this is why we have our results to be equal to one.
You can also add items in your list.
So if I write fruits May one equal to three, since melon is not in our list, we don't have such a
fruit there.
This means it will be added the site.
So let's run this code and you can see that melon has been added and its price is three dollars.
And finally, we can simply check if some item is on our list.
So let's check now if the banana is on our list.
If I write the print and then banana in.
Fruits, then I.