Hi everyone In the following several video clips, we study dictionaries and sets. Dictionaries and sets are similar in that they share the same notation here, curly bracket. All elements of dictionaries and sets are contained in a pair of curly brackets, but they are different in that dictionaries contain only paired data, but in case of a set, all data elements exist individually. So dictionaries store data in key value pairs as you saw in an English dictionary. In an english dictionary there's word list, word lists are keys. And for each word there is a corresponding definition of that word. That definition of that word becomes value corresponding to a specific key. So the structure of English dictionary is quite similar to the structure of dictionaries used in python. A set of data is an ordered collection of data which are unique and immutable. So duplication in a set is not allowed. Dictionaries and sets are interables but slicing with index is not allowed, why, because they are not ordered, they are not indexed. So all elements in dictionaries and sets are not ordered, are not indexed. That's why slicing with index is impossible. Now, let me explain dictionaries in more detail. Keys in dictionaries must be unique, overlapping is not allowed and keys are immutable. However, the same two different key values can have the same values. What I'm saying here is that keys must be unique but different two keys can have the same values, corresponding values. Dictionaries were often used in machine learning and deep learning for feeding data in the past. But nowadays in Tensorflow 2.0 world, you don't have to yours dictionaries to feed data. You set up instead pipeline for providing data. So nowadays dictionaries are not often used in feeding data in machine learning and deep learning. Now, let me give you some examples of making dictionaries. First, look at this one here, a object is an empty dictionary, right? But as I said before, dictionaries and sets share their same notation curly brackets, then what about you want to create empty set? Then because their notations are the same, the empty dictionary probably looks like empty set, right? The same notation encoding cannot be used for describing or presenting two different objects. So if you use empty curly bracket, it means that it is an empty dictionary. If you want to make an empty set, you have to use set function here. So let's execute this cell and see the answer. So type of a is dictionary and the object is just set, a is an empty dictionary, b is an empty set. So that is one thing you remember. Now let's make a dictionary Countries. The country's object contains four countries. And so country names are used as keys and corresponding values are simplified, nation notations in case of Korea, kr is a value matching to the full name, Korea. Japan jp, Spain es, Finland is fi. So paired data separated by comma. Also all elements in a set are separated by comma. So in that perspective, there is also another similarity between dictionaries and sets. All elements in dictionaries and sets are separated by commas. So if we print countries, the pair, each pair will be printed and the length of a dictionary counts the number of paired data reading a dictionary. And if you add keyword Korea reading square bracket after object name, it means that it returns value matching to Korea. So let's execute this cell. And what we see is here's a dictionary that we created and assigned this dictionary to the object countries and the length is for four element paired data are contained in the object and kr value is returned. Here's an example of dictionary operations, Korea asking whether Korea is in the object countries. In this case Korea has lower case first letter. It means that in python case sensitive, so probably the answer forests will be printed. So it is a way of checking Korea is in the dictionary. And by assigning specific value, you can replace value matching to Korea keyword. So in this case, kr will be replaced by country code 82 and we can print countries then we will see different modified country dictionaries. Also we can use update function in order to change specific value to Japan keyword. So we execute this third then here, in case Korea and Japan values to matching country names, I changed it. So you can use update function or you can use this a little bit simpler syntax for replacing values matching to key words. Another dictionary operation is introducing the following cell, in this case Canada and ca but Canada was not included in countries dictionary. In this case, new pair will be added. So it is a way of adding new data element in an existing dictionary. Surely you can use update function in order to add another pair of data element. So in this case Canada and China pairs are added. So Canada in the first case is added and China is also added in the second case. What if you want to delete a key, if you delete a key from existing dictionary, value will also be deleted because they are always paired. So what if we delete Korea from countries, then obviously Korea disappeared. Then how can you check whether Korea is existing in a dictionary, previously we have seen in conditions here, you can check whether Korea is in countries dictionary, but you can also use another notation, get Korea. If Korea exists in that case the value of Korea will be returned, but obviously we deleted Korea. So what happens here? If you use get function? None. Korea is not existing in the dictionary countries. So rather than returning it returns 93, none. So what about we change Korea into Japan. Then what happens? Japan is in the country's dictionary and its value will be returned 81, right? But what about instead of get function we use this one. Countries and Korea notation, Korea key value. Then what happens, error message appears. So obviously pacing our message is a little bit uncomfortable encoding so if you use get function you can avoid that possibility. Now, before closing this video clip, let me ask you a question, true or false. Dictionaries and sets are not ordered the collections of data, true or false? Obviously it is very easy question and the answer is true. Dictionaries and sets are not ordered as well as not indexed.