Lesson 1: Lists Explore

Overview

Students will learn the ways that lists are created, accessed, and changed through a teacher-guided activity using plastic baggies and pieces of paper. The lesson begins with a brief reflection on the value of lists. Students then complete the main activity which introduces the syntax to use lists and the ways they can be used. To wrap up students watch two short videos on lists and record the main concepts in their journals.

Purpose

In the warmup, students brainstorm different lists of information that they encounter on a daily basis. Then in the activity, students return to baggies and sticky notes from the previous unit to build a concrete model of a list before seeing how lists are programmed in Javascript. Students are exposed to different ways of interacting with a list like accessing, removing, appending, and inserting elements. The wrap up concludes the lesson with a summary video and a journal vocabulary exercise.

Agenda

Lesson Modifications

Warm Up (5 mins)

Activity (30 mins)

Wrap Up (10 mins)

View on Code Studio

Objectives

Students will be able to:

  • Use appropriate vocabulary to describe lists.
  • Use an index to reference specific elements in a list

Preparation

  • 7+ sandwich baggies per pair of students
  • 1 gallon-sized baggy per pair of students
  • packs of red and orange stickies
  • pens / pencils
  • 1 dry erase marker per four students (pairs can share)
  • Review the slides and click through all animations

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

Teaching Guide

Lesson Modifications

Attention, teachers! If you are teaching virtually or in a socially-distanced classroom, please read the full lesson plan below, then click here to access the modifications.

Warm Up (5 mins)

Preview Lists

Discussion Goal

Discussion Goal:

  • Lists help us group together like information
  • We can go through a list item by item to check off things we have completed
  • Lists help us stay organized

Prompt: With a partner, brainstorm lists of information that you encounter on a daily basis. Why are lists useful?

Discuss: Have students discuss with a partner and then have a few students share out their responses.

Activity (30 mins)

Lists

Group: Group students in pairs.

Distribute: Give each pair of students:

  • A small stack of red and orange sticky notes
  • A pen/pencil
  • 7+ snack-sized plastic baggies
  • One gallon-sized plastic baggy
  • A dry erase marker to share with another group

Display: Use the activity slides for this lesson to guide the unplugged activity on Conditionals.

Slides                     Speaker Notes
Say: Today, we are going to explore lists.

Note: Supplies Substitutions

  • There's no need to use stickie notes if you have other scraps of colored paper. Also consider cutting stickies in 4 to make them go further. If you don't have dry erase markers handy consider using pieces of masking tape on the baggies.
  • The gallon-sized baggie can be replaced with any baggie that is large enough to hold the snack-sized baggies.
Say: We’ve already learned that variables can help us store one piece of information.
Say: But what if we have lots of information?

Do This: With a partner, discuss the challenges that you’d encounter if you need to store 10, or 100, or 1,000 pieces of information using variables.

Discuss: Lead a short discussion on the challenges they’d encounter. The main challenges are that you’d need to make a variable for each piece of information and it could get difficult to name them all.
Say: Let's look at how to use lists
Say: Today we’re going to practice using a new way to store information called a list. Follow the instructions here to make a list of your own.

Do This: Have students create their own list. Circulate the room to check on how they’re doing. Make sure they share with another group.
Say: Your list is made up of elements. Each element has its own index. Indexes are just numbers that count up from zero. The length of the list is how many elements it contains. This list has 3 elements and indexes from 0 to 2.
Say: Notice that all the bags can folded up and be placed inside the big variable baggie. Sometimes we want to think about the whole list, sometimes we want to think about individual elements
Say: We create a list with this command. It creates a new list and assigns it to a variable. The square brackets indicate we’re making a list. Each value is separated by commas.

Do This: Have students write the command to make their own list and the list of partner group. By sharing their answers with another group they can check that they’re following along.
Say: If we want to access the values in our list we use the square brackets next to the name of our list.

Do This: Have students discuss with other groups. They should see the answers are “nachos” and “soup”
Say: We can use list accesses inside of expressions, just like variables.

Click for animation

Say: This first expression evaluates to 23 because myNumbers[1] contains 20.

Click for animation

Say: This second expression evaluates to 35 because myNumbers[0] and myNumbers[2] contain 25 and 10.

Do This: Have students write three expressions using their own lists. Then have them trade with another group to practice evaluating. Circulate the room to make sure students are following the directions correctly.
Say: We can assign the index of a list just like a variable.

Do This: Have students discuss what the list will contain after line 02 runs.

Click for animation

Say: This code will assign a new value at index 2 of the list.
Do This: Circulate the room while students run this program

Click for animation

Discuss: Discuss quickly with the class why the program ends with the list shown.
Do This: Circulate the room while students run this program

Click for animation

Discuss: Discuss quickly with the class why the program ends with the list shown.

Note: Line 02 is tricky. You need to first evaluate myStuff[0] which is “dog” to determine the value being assigned. Then evaluate myStuff[2], which is 3. At this point, the command reads myStuff[3] = “dog”. Now it is just a simple assignment.
Say: Now let’s learn about three different commands that can change your list.
Say: The removeItem command will remove an item from a list. The item at the index given is removed, items to the right are shifted over, and the last index is removed.

Do This: Have students discuss what the list will show after this command.

Click for animation

Discuss: Discuss with the class any questions.
Say: The appendITem command will add an item to a list. A new index is added to the end of the list and the new item is place in it.

Do This: Have students discuss what the list will show after this command.

Click for animation

Discuss: Discuss with the class any questions.
Say: The insertItem command will add an item to the middle of a list. The item is placed in the index given. Then every item is moved over one space to make room. A new index is aded to the end of the list to make room.

Do This: Have students discuss what the list will show after this command.

Click for animation

Discuss: Discuss with the class any questions.
Do This: Have students run this program. Circulate the room to support them with any questions.

Click for animation

Discuss: Discuss with the class any questions.
Do This: Have students run this program. Circulate the room to support them with any questions.

Click for animation

Discuss: Discuss with the class any questions.

Wrap Up (10 mins)

Video and Vocabulary

Video: As a class watch both videos on lists.

Do This: Review Key Takeaways and have students add to their journals: lists, element, and index.


Assessment: Check For Understanding

Check For Understanding Question(s) and solutions can be found in each lesson on Code Studio. These questions can be used for an exit ticket.

Question: Match the index with the value. var myNumbers = [32, 64, 33, 0, 15, 26, 3]

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.

CSP2021

AAP-1 - To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways
AAP-1.C - Represent a list or string using a variable.
  • AAP-1.C.1 - A list is an ordered sequence of elements. For example, [value1, value2, value3, …] describes a list where value1 is the first element, value 2 is the second element, value 3 is the third element, and so on.
  • AAP-1.C.2 - An element is an individual value in a list that is assigned a unique index.
  • AAP-1.C.3 - An index is a common method for referencing the elements in a list or string using natural numbers.
AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.N - For list operations: a. Write expressions that use list indexing and list procedures. b. Evaluate expressions that use list indexing and list procedures.
  • AAP-2.N.2 - List procedures are implemented in accordance with the syntax rules of the programming language.
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
  • AAP-2.O.3 - The exam reference sheet providesFOR EACH item IN aList{ <block of statements>}The variable item is assigned the value of each element of aList sequentially, in order, from the first element to the last element. The code in block of statements is exe
  • AAP-2.O.4 - Knowledge of existing algorithms that use iteration can help in constructing new algorithms. Some examples of existing algorithms that are often used with lists include:●       determining a minimum or maximum value in a list●       computing a sum or a