Lesson 3: Lists Practice
45 minutes
Overview
Practice the basics of lists including creating lists and accessing, inserting, and removing elements from lists.
Standards
AAP-1 - To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways.
AAP-1.D - For data abstraction: a. Develop data abstraction using lists to store multiple elements. b. Explain how the use of data abstraction manages complexity in program code.
- AAP-1.D.7 - The exam reference sheet provides the notation [value1, value2, value3…] to create a list with those values as the first, second, third, and so on items. For example, ● aList ← [value1, value2, value3,...] creates a new list that contains the values value1, value2, value3, and ... at indices 1, 2, 3, and ... respectively and assigns it to aList. aList ← [] creates a new empty list and assigns it to aList.
- AAP-1.D.8 - The exam reference sheet describes a list structure whose index values are 1 through the number of elements in the list, inclusive. For all list operations, if a list index is less than 1 or greater than the length of the list, an error message is produced and the program will terminate.
AAP-2 - The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.
AAP-2.D - Evaluate expressions that manipulate strings.
- AAP-2.D.2 - A substring is part of an existing string.
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.1 - The exam reference sheet provides basic operations on lists, including: ● accessing an element by index ● aList[i] accesses the element of aList at index i. The first element of aList is at index 1 and accessed using the notation aList[1]. ● assigning a value of an element of a list to a variable x aList ← [i] assigns the value of aList[i] to the variable x. ● assigning a value to an element of a list aList[i] ← x assigns the value of x to aList[i].
- 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 executed once for each assignment of item.
AP - Algorithms & Programming
- 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
Agenda
Objectives
Students will be able to:
- Accurately use list operations including accessing, inserting, and removing elements
- Correctly set up a list in a program
- Debug programs with lists
Preparation
- Review the slide on string indexes which you'll cover at the beginning of the lesson
- Review the programming progression to understand what students will be asked to do.
- Check the "Teacher's Lounge" forum for verified teachers to find additional strategies or resources shared by fellow teachers
- If you are teaching virtually, consider checking our Virtual Lesson Modifications
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the teachers
Teaching Guide
Warm Up (5 minutes)
Quick Warm Up
Remarks
Today we're going to have a chance to practice programming with a lot of the concepts and patterns we've explored over the last two lessons. I encourage you to go through these with a partner, but pay close attention to what each other is doing. You will be choosing one of three apps to help develop today. While the design of each of these apps is complete, it will be your job to use your knowledge of lists in order to make the apps function as intended.
Whichever app you choose, please continue to choose that same app on each of the choice levels. There are a total of ten levels for each app.
In our next lesson you're going to have to use a lot of these skills on an independent project, and these activities are good practice for what you'll find there! Alright, let's get to it!
Move Quickly to the Activity: There's a lot in the main activity of today's lesson. It is advisable to give students more time to get hands on with some code.
Activity (35 minutes)
Practice Time (35 minutes)
Group: It is recommended that students work in pairs for this lesson. Consider using pair programming, having drivers and navigators switch every 3 minutes, not every level.
Do This: Direct students to Code Studio, Lesson 3 Level 1.
Create Performance Task Written Response Practice
In order to help prepare students for the new component of the AP Create Performance Task, there will be several opportunities throughout the curriculum to practice creating written responses aligned with the learning objectives that might be assessed on the exam.
Sample Prompt: Identify the number of times the body of your iteration statement will execute. Describe a condition or error that would cause your iteration statement to not terminate and cause an infinite loop. If no such condition or error exists, explain how the loop could be modified to cause an infinite loop.
Wrap Up (5 minutes)
Discuss: What aspects of working with lists do you feel like clicked today? What do you still feel like you have trouble with?
Discussion Goal: Use this opportunity to address any lingering questions or misconceptions in the room. You can also use this as a source of discussion topics to kick off the following lesson. As you lead the discussion, call out the many resources students have access to help when they're getting stuck.
Remarks
Lists can be a little bit tricky, but I saw a lot of good progress today in nailing down this concept. We may have a few lingering questions, but you also have a lot of resources available. Next time you'll have a chance to put all this together by programming an app that starts with "the blank screen"!
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.