Hello, in this video, we are going to look at dictionaries within Python. So you can, this will have like a, like a hash table type, and they have key value pairs, you can think of them, you know, in a very similar fashion to arrays as well. So to create a dictionary, we're just going to call it ditch braces. Now, you could demand the dictionary to sign the value, we first put a key, so this has to be unique. So if I put one for example, that's a key can be a number can be a string doesn't matter. That's if we assign this the value of items.
And if creating a one dictionary, and two equals two, and let's do another one dictionary For equals item. For this one, we're going to set it to a string. So I'm going to say, Hello. So this is the key for this particular item. So we can print it off for using print dictionary. And what we can do, we need to access it so we can access it via like one for example, we can print off another one, we'll print them all out too.
And for the final one, we need to use the key because at the end of the day, we have a string of the key. So if I run this, and let's see what we get. And then some error. So Miss missing parentheses and call to prayer. Keep doing this. So if I run it again, and there we go.
So we can also just print off the entire dictionary, like so we can print off just the values of the dictionary. So dot value. And this is a method that returns all the values. And we can also print off a all of the keys as well. So let's see what we get. There, run it.
There we go. So the entire dictionary, just the values of the dictionary, and then the keys. So With valid OCR to one or two, item three, and so happened to be your string, you could, you know, literally put a number there floating point number five, after the keys, one, two, and Hello. So this corresponds with this one, this one, this one, and this one, this one, this one, nothing I want to show you. And what I'm going to do is create a new dictionary, so to call this time, new dictionary, like so. And if we assign it, some curly braces, but this time, what we're going to do is do it all in line.
So a setting gonna create this dictionary go here, we just if we know only, let's say some of the initial values, we can just do this we can put one and then we can put a colon, like so. And now we specify the value. So one Pour a comma, we can put two. And now we can specify value it to. And now patello to the games is trying to simulate the first dictionary, we can put it on free. So the format is the key colon, which separates the key and the value, then the value again, this could be a number, comma, separate each key value pair.
And now what we'll do is just do a brand new dictionary, and what to print off them the new dictionary, obviously, you can see how to access the values, you can see the different methods, and they're all applicable as well. So I just want to make sure it works. So as you can see, this is printed off, and it's the exact same format even though we did it all in one line, and you can obviously data values by just reusing that particular key or just overwrite that particular value. You can add more values wherever it's to this one. Water, this dictionary by just specifying a whole new cases is really great for grouping common data and nothing. dictionaries, you know, aren't ordered in any sense.
So they're not out of order. They're just, you know, on orbit. So that's it for this demo. Thank you for watching, and I'll see you in the next video.