AP CSP CodeX - Lists Lesson 1

Lists Lesson 1 Lesson Plan

Lists Lesson 1

Students build a mental model of lists, then trace code that uses list indexes and list methods.

⏰ 45 min 🎯 Grades 9-12 🎮 CodeX 🐍 Python
View Lesson Outline
📋

Overview

This unplugged lesson builds on the lists students met in Mission 7. Working in groups, students use baggies and slips of paper to build a mental model of a list. They learn the list vocabulary and list methods, then practice by tracing code in the Group Code Tracing examples. The Lists Lesson 1 Activity Guide is used as a review after the group work. Lists continue in Lists Lesson 2, where students get more practice.

🎯 Mission Goal: Students will evaluate code segments that involve lists and list methods.

🎯

Learning Targets

  • I can define and identify parts of a list.
  • I can access an element of a list.
  • I can evaluate code segments with lists and list methods.
💡

Key Concepts

  • A list can be used when you have, or could have, many similar variables.
  • A list has elements, or items, organized in order by number.
  • The number used to organize the elements is called an index.
  • Data in a list can be changed, removed, inserted, and used in calculations.
✅

Assessment Opportunities

☑️

Success Criteria

  • Define list vocabulary
  • Access and manipulate elements in a list
  • Evaluate list code segments
🧰

Classroom Materials

  • ▸Printed copies of the Group Code Tracing examples (one set per group)
  • ▸Optional: baggies, slips of paper, tape, and pieces of paper or small whiteboards for creating a list mental model
🌍

Real-World Applications

✅To-do lists: People use these to manage daily tasks, work assignments, and household chores.
🛒Shopping lists: Shoppers write down items they need to buy before going to the store to save time and prevent forgotten items.
🎵Playlists: Music services arrange songs in a specific order so users can play their favorites back-to-back. The playlist can change from day to day.
🚀

Extensions & Cross-Curricular

ExtensionStudents write their own code tracing problem with at least five list operations, trade with another group, and compare answers.
ExtensionStudents look at their Mission 7 Personal Billboard program and point out the list, an index, and the length of the list.
MathStudents compare lists to number sequences in math, where each term has a position, and discuss why a list starts counting at index 0.
Lang ArtsStudents use a daily reflection journal to explain list, index, and element in their own words.
🔤

Vocabulary

▾

The vocabulary terms are reviewed from Mission 7.

List - A sequence of items you can access with an index. An ordered collection of elements.
Index - A number that keeps track of what choice should be displayed. A common method for referencing the elements in a list or string using numbers.
Item - An individual value in a list that is assigned a unique index.
List Length - How many items the list contains. Lists can grow or shrink as elements are added or removed. You can calculate the current length by using the function: len(list_name)
Data abstraction - The process of hiding details and showing only essential information to the user. A list is a form of data abstraction because it gives a sequence of items a name that all items can then be referenced with.
🐍

New Python Code

▾

Some of the Python code is a review from Mission 7.

a_list = []Define an empty list.
a_list = [0, 1, 2, 3, 4, 5, 6, 7]
b_list = ["Hello", "Hi", "Hey"]
Define a list with items.
my_num = a_list[3]Assign a value to a variable from a list. In this example, the value at index 3, which is 3, is assigned to the variable.
a_list[3] = a_list[3] + a_list[4]Use items in a list as part of a calculation. In this example, the new value of a_list[3] would be 7.
len(a_list)Returns the number of items in the list.
a_list.append(new_item)Adds the new item at the end of the list.
a_list.insert(index, item)Inserts the new item at the given index. All items after that have an index increased by 1.
a_list.pop(index)Removes the item at the given index. All items after the removed item have an index decreased by 1.
📐

Standards

▾

CSTA Standards - Grades 9-10

3A-CS-01 3A-AP-14

CSTA Standards - Grades 11-12

3B-AP-12

AP CSP Framework - Algorithms and Programming

AAP-1.C - Represent a list or string using a variable.
AAP-2.N - Evaluate expressions that use list indexing and list procedures.

AP CSP Framework - Computational Thinking Practices

3.A - Generalize data sources through variables.
4.B - Determine the result of code segments.
6.A - Collaborate in the development of solutions.
📝
Preparing for the Lesson
  • Print the Group Code Tracing examples (Example #A and Example #B) for each student group.
  • The Activity Guide can be distributed digitally. It is used as a review after the group work.
  • Gather supplies for the list mental model: baggies, slips of paper, and tape (or magnets for magnetic boards), or small whiteboards.

🧑‍🏫
Teacher Notes
  • This lesson is best with partners or in groups of three.
  • Students do not work at computers for this lesson.
  • The programming concept of lists continues in the next lesson, where students are given more practice.
  • The Lesson Outline gives the narration for one way to present the lesson and help students develop a mental model of lists. Modify the slides (or lesson) as needed.
🗺️

Lesson Outline

This outline gives the narration for one way to present the lesson.

🗣️Warm-up

In the last lesson (Mission 7) you were introduced to lists and how they can increase the functionality of a program. Today we are going to create a mental model of lists and practice working with list elements.

What are some examples of lists in your everyday life?

Possible answers:

  • Song playlists
  • To-do lists
  • Grocery or shopping lists
  • Phone contacts

What is a variable? What are some limitations of variables? (A variable can only hold one value at a time.)

🧠Teacher-Led Mental Model

💻 Students will NOT work at computers for this lesson. Groups of three standing at vertical whiteboards work well.

Teaching tip: Students can use small whiteboards or baggies (or other containers) to represent individual variables. Baggies are used as the example here, so modify as needed if your students use something else as their variable containers.

📓 Preparation: Have students work in groups of three at vertical whiteboards. Each student will need one to three baggies and slips of paper to write on. Students at whiteboards may need tape to connect their baggies together. Students at magnetic boards will need magnets.

🧑‍🤝‍🧑 Say (Example #1):

  • Think about your favorite candy. Write it down on a slip of paper and put it in the baggie.
  • These baggies represent individual variables. How many variables does your group need to represent all the favorite candies?
  • You probably have more than one favorite candy. Write your other favorite candy on more slips of paper, and put each one in a separate baggie. Remember - each baggie, or variable, can only hold one value!
  • If you want to write a program that uses all the favorite candies, how many variables would you need? What if you have more favorites? What if you change your mind and have fewer? How will these changes affect your code?
  • All the variables are related. They could be called candy1, candy2, candy3, etc. Instead of creating all these individual variables, wouldn't it be better to have ONE variable that could hold all the values? SURE! And we have this capability with lists.
  • Tape your baggies together in a line to create a list.
  • The order you taped your baggies is the order of the list. Now that we have a list, how can you access a single candy? We number them! Computers start counting at 0, so starting with 0, number each of your candies.
  • The number of each candy is called an index, and the candy (or value) is called an element.
  • How many elements are in your list of candies? Notice that the length of the list (number of elements) is one more than the last index.
  • What would you call your list? What should its name be? The programming convention is to use a plural noun for lists. This is a visual clue that you are working with a list instead of a variable.

🧑‍🤝‍🧑 Say (Example #2): Students continue in their groups. They can use baggies, pieces of paper, individual whiteboards, etc. for their individual variables.

  • Think of your favorite number. Write it on a piece of paper or whiteboard.
  • Now perhaps you have another favorite number. Write it on another whiteboard.
  • Think about how many variables you need to represent all these numbers.
  • How can you represent all the numbers as a list?
  • Have students create a list of their favorite numbers.

🧑‍🤝‍🧑 Show: Display slides 16-19. List vocabulary and definitions. End with going over the definitions of list, index, and item.

💡 Working with Lists: Go over slides 20-22. These give examples of defining a list, using a list, and modifying a list.

👥Group Practice

💻 Students continue in their groups of three at the vertical whiteboards. Print the two examples in advance and have them ready for students to work through.

Teaching tip: Students have two examples to work through in their groups. They can do them in either order. They should compare their answers with other groups and discuss or re-work examples they do not agree on. The teacher can monitor and support as needed.

Answers to Examples:

  • Example #A: Final alist = [20, 5, 6, 1, 7]
  • Example #B: Final blist = [4, 10, 5, 11, 9, 1]
🧑‍🤝‍🧑Wrap-Up

Students work on the Activity Guide as a review of the lesson. The Activity Guide can be completed individually or in small groups.

✅ Formative assessment:

  • Lists Lesson 1 Activity Guide
  • Daily reflection journal or Google Form
  • Class discussion on what they learned about lists
  • Exit ticket