Loading video player…

Python Basics: Dictionaries (Overview)

In plain English, a dictionary is a book containing the definitions of words. Each entry in a dictionary has two parts: the word being defined, and its definition.

Python dictionaries, like lists and tuples, store a collection of objects. However, instead of storing objects in a sequence, dictionaries hold information in pairs of data called key-value pairs. That is, each object in a dictionary has two parts: a key and a value. Each key is assigned a single value, which defines the relationship between the two sets.

In this video course, you’ll learn:

  • What a dictionary is and how it’s structured
  • How dictionaries differ from other data structures
  • How to define and use dictionaries in your own code

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3. You can also check out the other Python Basics courses.

Note that you’ll be using IDLE to interact with Python throughout this course. Before you start, you might find it helpful to revisit Python Basics: Setting Up Python or check out Starting With Python IDLE.


Sample Code (.zip)

1.1 KB

Course Slides (.pdf)

5.8 MB

00:00 Welcome to Python Basics: Dictionaries. Maybe you’ve already learned about lists and tuples in Python, and in this course you’ll get to know dictionaries, which is another super useful data structure in Python.

00:14 Dictionaries are used frequently for solving all kinds of programming problems, so they are a fundamental piece of your tool kit as a Python developer. I’m Philipp from Real Python, and today we’ll talk about dictionaries.

00:28 During this course, you’ll be using IDLE, which stands for Integrated Development and Learning Environment. IDLE comes with most Python distributions out of the box.

00:39 If you need a quick refresher on using IDLE, then check out one of our video course in the Python Basic series entitled Setting Up Python. Alternatively, if you want to take a deeper dive, then you may watch the Starting With Python IDLE video course. Of course, you can use any other editor of your choice, but if you want to follow along closely, it’s a good idea to stick with IDLE for this video course.

01:05 In this course, you’ll learn all the basics that you need to know about dictionaries. Here is the table of contents for this course. Currently, you are in the overview lesson. Next, I’ll give you a short introduction to what a dictionary is, and then you’ll learn how to create a dictionary and work with them.

01:23 I’ll show you how to access values and how to add and remove values.

01:27 Sometimes you’re not sure what’s in a dictionary, so in lesson five, you’ll learn how to check for the existence of dictionary keys. Dictionaries are iterable.

01:39 That means you can loop over them. You’ll do this so often in your programming life that it’s worth its own lesson in this course, lesson six. If you can’t get enough of dictionaries, how about adding a dictionary to a dictionary?

01:53 I’ll show you how to nest dictionaries in lesson seven.

01:57 Lesson eight is a special lesson. In this lesson, I’ll give you a challenge to test your knowledge about Python dictionaries. We’ll wrap up this course with a summary about all the things you learned, and I’ll send you off with links to a bunch of helpful resources that you can find on Real Python. Okay, let’s get started.

Become a Member to join the conversation.