Python Programming 15. Dictionaries
This is the 15th in a course of computer science video lessons introducing programming with Python. This lesson covers the dictionary data structure. A dictionary is ideal for storing data when fast retrieval of individual data values is important. You will learn that each dictionary item includes a key and a value. A key can be almost anything, as long as it’s unique. Usually, each key is a meaningful string. For example, each key could be a person’s name and the corresponding value could be their phone number, which you want to look up. Since the value can also be a list, several pieces of information can be stored along with one key, for example, someone’s address, occupation, salary, and so on. You will learn how dictionary data are stored behind the scenes, in a hash table, and the implications of this on the performance of a dictionary. You will also learn how to work with a dictionary in code using various methods and commands. Chapters: 00:00 Create a new dictionary 00:41 Retrieve an item from a dictionary 01:01 How a dictionary works – hash table 05:45 Working with a dictionary 06:32 The get method 07:05 Add a new key value pair 07:44 Add several key value pairs with the update method 08:10 Create an empty dictionary 08:29 The dictionary merge operator 09:07 Remove a key value pair 09:26 The pop method 09:54 Clear a dictionary 10:12 Summary of commands so far 10:25 Duplicate keys 11:25 Testing for a specific item 11:42 Store multiple values for one key in a dictionary of lists 13:47 The keys, values and items methods 14:57 Create a list of keys 15:16 Iterate through the values and keys with a for loop 15:58 Check existence of a key with if and the in operator 16:38 Create a dictionary from a lists of keys and values with zip 17:22 Summary
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.