Data Structures
You've been using data since your very first "Hello, world". You've practiced with strings and lists. You've used functions, loops, and conditionals to organize your code to solve problems. Now, you'll shift your focus to how to organize your data to solve problems.
Lists and strings are data structures. You've seen how they've been useful for solving whole sets of problems, that they are the right kind of fit for. You may have also run into some problems that were tricky to solve. Some of those problems can be made much easier, if you are familiar with different data structures.
These lessons will focus on using dictionaries. Next to lists, dictionaries are the most common data structure you'll use for solving problems in python. Instead of a series of items accessed by a numeric index, dictionaries let you access items using a name. Since dicts can access items by name quickly, they make it easy to solve problems that lists aren't well-suited for.
Other built-in Python data structures include set
and tuple
, and there are tons of more specialized data structures, like the deque
(pronounced 'deck'), namedtuple
, or struct
. You won't learn about those in these lessons, but with two go-to choices for data structure available to you, you'll start to ask the question: "what is the right data structure for this problem?"
Learning Objectives
After these lessons, you'll be able to:
- Create, update, and read data from Python dictionaries
- Use dictionaries to solve problems
- Recognize which kinds of problems are well-suited for dictionaries, and which ones are better suited for lists