Lab 2: Contact List

Goal: review lists, abstract data types, and for each; develop deeper understanding of abstract data types (if we keep display and sorting form selectors)

Computers manipulate data and return processed information to the user. Numbers, strings of characters (letters, numbers, symbols, etc.), and Boolean values (true, false) are some of the basic pieces of information. Often, these small pieces are arranged in more complex structures: lists, ordered sets of data.

A list is not just a collection (set) but also a collection in a particular order (this order is tracked by an index number for each item on the list). If it has any elements at all, it has a first element, a last element, and so on. A list can also be totally empty, with no elements; often that is the way we want to set up (initialize) a list before we add elements to it. The length of an empty list is 0.

Lists are powerful. Databases are lists of lists of lists. Many operations can be performed on data in a list:

Lists can contain anything: numbers, strings, other lists, even blocks. The objects in a list can be all of the same kind (all numbers, for example, or all lists that contain a name and a phone number) but they do not have to be. A list can, for example, contain an apartment number and a list of people at that address. The tabular data we are familiar with in spreadsheets can be represented as a list of same-length lists, the smaller lists representing each row in the table, and the enclosing list representing the entire spreadsheet.

In this lab, students construct a contact list app. The list's elements are themselves lists. This requires not only collecting and storing information, but being able to retrieve it in useful ways.

Pacing

The 4 required lab pages could be split across 2–4 days (85–170 minutes). Expected times to complete follow:

Prepare

A Few General Tips:

Lab Pages

Solutions

Correlation with 2020 AP CS Principles Framework 

Computational Thinking Practices: Skills

Learning Objectives:

Essential Knowledge: