All right we are in the homestretch everybody.
So we're going to cover dictionaries now and when we think of dictionaries we need to think of key value
pairs.
So let's go ahead and make a do section called dictionaries and we'll just note key value pairs.
Probably put a slash here key slash value pairs.
And we'll also put a little note of curly braces like this so let's talk dictionaries.
So let's say we have a dictionary and we want to have a menu.
Let's make a drink menu again.
Make this however you want.
I'm going to make this based on some alcoholic beverages.
You can absolutely make this more you know Fiji or Fiji 13 or however you want to make it.
But let's say a white Russian.
You go to a bar there's a white Russian on the menu and that White Russian cost seven dollars.
And there's also an old fashion and leaders say that's 10 bucks and then we have lemon drop which is
eight dollars.
So we've got these and we'll close the office with a curly bracket.
And this is what a dictionary looks like.
So if you were to print out drinks we would return our dictionary.
Let's do that.
If I would make this the correct syntax this would work very well for me.
I am human after all.
So you see here white Russian is seven old fashioned ten lemon drop eight.
So you can note here is that the drink is your key and your price is your is your value.
So you have your key value pair here.
So key value key value key value.
Well think of it as another way.
We don't have to just have one parameter or one value.
We have to have a key.
We can have multiple values to a key.
So let's talk about employees.
I'm going to use one of my favorite TV show which is Bob's Burgers to do this.
So let's say we have employees and we have different departments.
So let's say we have a finance department OK.
And inside the finance department we've got Bob.
We've got Linda and we've got Tina.
We have three employees in the finance department.
Then we've got an I.T. department.
And inside of I.T. there might be Gene and Louise.
I will add Teddy to this too.
I'm not going to have to move this over.
So a little bit long and then let's do one more department.
Let's say that there's a Department of H.R. our favorite department and we'll say there's Jimmy Junior
and Mort.
All right.
So this is our dictionary.
Now again we can print out employees and we should be able to see our dictionary here say this.
Give it a print.
Okay.
You can see finance as Bob Linda Tina I.T. has Jean Louise and Teddy and Jimmy Junior and more are in
age are.
I'm gonna fix this typo and.
All right.
So let's say that we want to add a new key value pair well we can say let's say there's a new department
and we could say there's a new department called legal employees and let's add in legal and then we'll
say in legal there is Mr. Frond.
All right and this will add a new key value pair something like this.
All right.
So let's save this.
Go ahead and just print it and if I were to write print afterwards grant employees and we'll save it
Let's print it one more time.
Now you see that legal has been added with Mr. Frond working in legal OK.
Let's do another let's say that we've added somebody to the sales team and let's do it this way.
We didn't have a sales team before but we do now.
So we can also do an update something like this.
We could say update and then we can add in sales
and we can say hey we've got a nice new sales team of Andy and Ollie
and look something like this.
So now we print out in plays we should have Andy and Holly on the sales team as well so there's multiple
ways to add in new key value pairs.
So we can copy this and paste it over here as a key value as well so we can also update things.
This is the last thing I'm going to show you.
We can also update things so we can say go back to our drinks.
Well let's say that we've got the White Russian let's say the White Russian is no longer seven dollars
our menu has changed and it's now eight dollars.
So we're going make eight dollars and we'll just print out drinks and we can save that print it and
I could see the White Russian is now eight dollars instead of seven from before we can also get some
items out of a dictionary.
So say print during stat get.
And will this get the White Russian.
And let's see what that returns.
So you pull specifically from a dictionary here and you see that the White Russian has a value of eight.
So this is it for dictionaries.
You're not going to really see it come up in this course.
But again this is another valuable thing with Python to know.
So we have covered lists which have brackets like this we've covered tuples which have parentheses and
then now we have covered dictionaries which have the curly braces.
And now when you're reading code you should be able to identify all of them differently.
This is why this was important.
Everything has been building upon up until this point.
Right.
So now you will identify.
Ok I see those curly braces.
That's going to be a dictionary or I see these these brackets here.
That's going to be a list.
So keep that in mind and moving forward you should be able to now start reading this code and understanding
this code in from the beginning I told you we don't have to be developers but we do have to be able
to read code.
So the more I show you the better off that you're going to be.
So we're going to wrap up this lesson.
We've got a couple more before we start building our scripts and we'll be a be good to go and move into
hacking so I'll catch you over in the next lesson.