00:00 The best way of introducing a dictionary is actually showing to work with it. Still, I want to give a little bit of more theoretical introduction to Python dictionaries. I promise this lesson is super short.
00:24 So here you have the word “Dog” and the definition “A mammal with sharp teeth, an excellent sense of smell, and a fine sense of hearing.” You also use a dictionary when you want to translate a word. So for example, the English word “Dog” is the German word “Hund.”
Another way of thinking of a dictionary is to think of it more like a form. For example, if you have a form for my dog, the name is Frieda, and the age is 5. On the right side, you see the data structure
my_dog translated into a Python dictionary.
01:09 Python dictionaries, like lists and tuples, store a collection of objects. Each object in a dictionary has two parts, a key and a value. Instead of storing objects in a sequence like lists or tuples do, dictionaries hold information in pairs of data called key-value pairs.
The key in a key-value pair is a unique name that identifies the value part of the pair. So here you’ve got the dictionary
"name": "Frieda" as an object and
"age": 5 as an object. The keys are
"age", and the values are
Become a Member to join the conversation.