Introducing Dictionaries
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.
00:09 I promise this lesson is super short.
00:13 In plain English, a dictionary is a book containing the definition of words. Each entry in a dictionary has two parts, the word being defined and its definition.
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.
00:36 So for example, the English word “Dog” is the German word “Hund.”
00:42 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.
00:52
On the right side, you see the data structure my_dog translated into a Python dictionary. Don’t worry so much about the syntax right now. I just wanted to show you how a dictionary looks in Python.
01:05 You will get into the details in the next lessons.
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.
01:29
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 my_dog with "name": "Frieda" as an object and "age": 5 as an object.
01:43
The keys are "name" and "age", and the values are "Frieda" and 5.
Become a Member to join the conversation.