AP CSP CodeX - Lists Lesson 1
Lists Lesson 1
Students build a mental model of lists, then trace code that uses list indexes and list methods.
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
Digital Resources
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
Extensions & Cross-Curricular
🔤
Vocabulary
▾
The vocabulary terms are reviewed from Mission 7.
🐍
New Python Code
▾
Some of the Python code is a review from Mission 7.
b_list = ["Hello", "Hi", "Hey"]Define a list with items.
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework - Algorithms and Programming
AP CSP Framework - Computational Thinking Practices
- 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.
- 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.
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.)
💻 Students will NOT work at computers for this lesson. Groups of three standing at vertical whiteboards work well.
📓 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.
💻 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.
Answers to Examples:
- Example #A: Final alist = [20, 5, 6, 1, 7]
- Example #B: Final blist = [4, 10, 5, 11, 9, 1]
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