Your programming roadmap
arrays, tuples, hash tables
You can combine multiple data types together to form composite data types.
Consider using the apply first, study second approach with the resources below: try a problem or exercise from the Apply It section first. If you get stuck, then use a course, book, or lecture in the Reference section. Or if you’re completely new to a topic, then learn just enough and apply right away. The point is: the quicker you get to the “doing,” the better the learning. Make your learning active.
The best way to get comfortable using arrays, tuples, hash tables is to solve problems with them. Then—and this is the important point—take time to study the solutions of others who’ve solved the same problem. It’s not enough to know how to use a map, for example. Rather, you need to know when and why it makes sense to use a hash table in this problem, and a tuple in that one. Studying the code of others is a great way to build this context.
Reuven Lerner’s book, Python Workout offers many problems that’ll give you practice with composite data types (see chapters 3 and 4). He also provides thorough explanations for each problem, as he walks you through the solution in an accompanying screencast. So few authors do this. It’s one thing to get the solution to a problem. It’s another thing to understand how you got there and why. Lerner dives into this context, which is why I find this resource valuable.
"I've missed more than 9000 shots in my career. I've lost almost 300 games. 26 times, I've been trusted to take the game winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed."
-Michael Jordan
For extra practice, use Brian Hogan’s electronic book, Exercises for Programmers. It offers practical, real-world exercises that are organized by topic. You’ll find problems related to composite data types in chapter 7. I like Hogan’s book because you can get a lot from each problem: solve the problem as asked; then add a provided constraint; then add a provided challenge.
Tip: If you get stuck on a problem, write—yes, write—the step you’re working on or the question you’re after. It’s easy to go in circles when you haven’t narrowed your focus on the precise thing that you need to do. So take a few seconds and jot down a few words. Doing so will help you to solidify your thought process and redirect your attention.
Take your knowledge a step further by solving problems on LeetCode. Sign up for an account, then filter the problems by “Array” or “Hash Table.” Note, too, that you can filter further by level of difficulty. And don’t forget: after you solve a problem, study the solutions of others who’ve solved the same problem (see the “Discuss” tab).
Learn X in Y minutes is a useful (and free) website to keep handy as a general reference as you work through the Pyramid. For our purposes here, use it to jog your memory on tuples or hash tables, for example. Select the language of your choice from the homepage. You’ll get a comprehensive write up of core aspects and features, and how they work, for that language.
The content on Learn X in Y minutes website is extensive. Just search for the specific topic you need (i.e. do a control find (“ctrl-f”) and type “boolean,” for example).
Lerner’s book, Python Workout, also contains brief explanations and examples of lists and tuples (chapter 3) and dictionaries (chapter 4). (Note: Arrays can be referred to as lists and dictionaries can be referred to as hash tables or maps in some languages). But, as I mention above, where this resource really shines is the screencast that accompanies each problem. You get far more than a solution, you get a solid understanding.