Chapter 7. Knitting variables into arrays and dictionaries

 

In chapter 3, I introduced the concept of variables to you, and now is the time to put them all together and use them in different ways: in arrays and dictionaries.

This chapter covers

  • What arrays and dictionaries are, and why you need them
  • How to store data in an array or a dictionary
  • How to use this data
  • How to add, delete, and modify your data
  • How to loop through an array or dictionary

You’ve reached milestone 7, knitting variables into arrays and dictionaries. In this chapter, you’ll be knitting variables together. You’ve been using variables in different situations for quite some time. Now you’ll learn about using them in arrays and dictionaries. The attendance register that lists your names in order, for example, is an array. Your test scores in the past five quizzes you took are an array as well.

Also, the glossary at the end of your math textbook is a dictionary that lists keywords like polygon, ratio, data, diagonal, and integers along with their definitions! In fact—which may come as a surprise to you—an English dictionary is a dictionary in programming as well!

Why do we need arrays and dictionaries?

What is an array?

10 Number Sorter app

Go to the second dimension (rows and columns)

What is a dictionary?

Friend List app

Check your app knowledge

App-Exercise: Alphabet Unscrambler