AP CSP CodeX - Traversing a List Lesson 2
Traversing a List Lesson 2
Students use for loops to traverse multiple lists and a 2D list to control the CodeX pixels.
Overview
Students work on computers in the CodeSpace Sandbox. This lesson is not part of a mission. Students modify Answer_Bot_traversals to use a for loop, then modify Pixels1_parameters to traverse two lists at the same time and finally one 2D list, or matrix. They complete the Wrap-Up questions on the Activity Guide, and optional challenges are available if time allows.
🎯 Mission Goal: Students will traverse a single list and multiple lists using a for loop in a program.
Learning Targets
- I can use a for loop to reduce repeated code.
- I can traverse multiple lists using a for loop.
- I can traverse a 2D list, or matrix, using a for loop.
Key Concepts
- Traversing a list means accessing each element in a list, in order.
- The easiest way to traverse a list is to use a for loop.
- You can traverse a list multiple times using a for loop.
- You can create a 2D (or 3D) list instead of having multiple lists.
Assessment Opportunities
- Traversing a List Lesson 2 Activity Guide
- Answer_Bot_traversals program
- Pixels1_traversals program
- Pixels1_matrix program
Success Criteria
- Use a for loop to turn on pixels
- Traverse multiple lists in a for loop
- Create a 2D list
- Traverse the 2D list in a for loop
Digital Resources
- ▸Traversing a List Lesson 2 slides
- ▸Traversing a List Lesson 2 Activity Guide
- ▸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- Make sure students can open their Answer_Bot_traversals and Pixels1_parameters programs in the CodeSpace Sandbox. Students who need the original code can use the most recent version of each program from the class dashboard.
- Prepare the Activity Guide to give to students. It is used for notes during the lesson and for the Wrap-Up questions at the end.
- If you have a word wall, or another form of vocabulary presentation, prepare the terms.
- Students complete this lesson on the computer, using the Sandbox in CodeSpace for programming. This lesson is not part of a mission.
- The lesson includes two challenges at the end. These are optional! This lesson is a little shorter than the first, so if there is time, have students try a challenge. But don't extend the lesson just to try the challenges.
- Students modify the Answer_Bot_traversals and Pixels1_parameters programs.
- The best experience will come from students modifying their own code. However, we want all students to be engaged, so you can give them the original code to modify if needed.
- The most recent version of each program can be found in the class dashboard. If you are giving code to students, use the solution code from these lessons:
- Answer_Bot_traversals: Unit 3 Traversing a List Lesson 1
- Pixels1_parameters: Unit 3 Functions with Parameters Lesson 1
- Solution code for all finished programs is provided.
- Follow the slides for instructions and guidance.
Lesson Outline
This outline gives one way to present the lesson.
Review loops and list traversal with students.
- Slide 2: Students answer questions in the Activity Guide.
- What do you remember about a for loop?
- What do you remember about traversing a list?
💻 Students take notes in the Activity Guide and modify the Answer_Bot_traversals program.
💻 Students take notes in the Activity Guide.
💻 Students use the Pixels1_parameters program from Unit 3 Functions with Parameters Lesson 1.
💻 Students continue with the Pixels1 program. This example introduces a matrix and how to define and traverse one.
💻 Go through slide 22 and discuss as needed. If you are not doing the challenges, skip to slide 25 for the wrap up.
💻 Complete the challenges if you have time. They are optional. If you do not do the challenges, you can delete or ignore the space on the Activity Guide for the challenges.
💻 Students do not use the computer for this activity.
✅ The Activity Guide and programs are complete and ready to turn in.
✅ Formative assessment:
- "Wrap-Up" questions at the end of the Activity Guide
- Daily reflection journal or Google Form
- Class discussion on what they learned about lists
- Exit ticket