Warm Up (5 minutes)
Activity (35 minutes)
Activity 2 (30 minutes)
Wrap Up (20 minutes)
If you get stuck on this: https://www.youtube.com/watch?v=pk32rysRQAg&t=12s
Key Take-Aways:
We use a for loop to traverse a list, visiting each element one at a time.
Each pass through the loop, the counting variable changes - usually by one. We can access each element by evaluating list[i] in the for loop.
Once we know the element at each spot in a list, we can do different things with it:
Filter (create a subset of elements from the original list)
Reduce (reduce the list down to a single element, for example: the smallest number in the list)
Traversal: the process of accessing each item in a list one at a time
List - an ordered sequence of elements.
Element - an individual value in a list that is assigned a unique index.
Index - a common method for referencing the elements in a list or string using natural numbers.
Iteration - a repetitive portion of an algorithm. Iteration repeats until a given condition is met.
Students practice traversing lists, filtering and reducing lists, and using the data import tools. Along the way students develop debugging practices with traversals.
Using Programming Patterns and a step-by-step approach students make their own version of a Random Forecaster app. At the beginning of the lesson students are able to explore a working version of the app. They are then given the design elements of the app but begin with a blank screen. Students use an Activity Guide to go through the high level steps they should use to develop their app but leaves it to them to decide how to write the code. At the end students submit their apps which can be assessed using a provided rubric.
This lesson is students primary opportunity to get hands on with lists in code prior to the Make activity in the following lesson. Give students as much class time as you can to work through these. For this lesson it's recommended that you place students in pairs as a support and to encourage discussion about the challenges or concepts they're seeing.
This lesson is an opportunity for students to take on the "blank screen" and build the code that runs an app entirely from scratch. Guidance provided throughout the lesson helps students break down the large task of "building an app" into more incremental steps that they can use on future projects, including this unit's final project and the Create PT.
CSP Conceptual Framework
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.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.1 - Traversing a list can be a complete traversal, where all elements in the list are accessed, or a partial traversal, where only a portion of elements are accessed. EXCLUSION STATEMENT (EK AAP-2.O.1): Traversing multiple lists at the same time using the same index for both (parallel traversals) is outside the scope of this course and the AP Exam.
AAP-2.O.2 - Iteration statements can be used to traverse a list.
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
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 average of a list of numbers
AAP-3 - Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing programmers to write programs more quickly and with more confidence.
AAP-3.F - For simulations: a. Explain how computers can be used to represent real-world phenomena or outcomes. b. Compare the use of simulations with real-world contexts.
AAP-3.F.1 - Simulations are abstractions of more complex objects or phenomena for a specific purpose.
AAP-3.F.2 - A simulation is a representation that uses varying sets of values to reflect the changing state of a phenomenon.
AAP-3.F.3 - Simulations often mimic real-world events with the purpose of drawing inferences, allowing investigation of a phenomenon without the constraints of the real world.
AAP-3.F.4 - The process of developing an abstract simulation involves removing specific details or simplifying functionality.
AAP-3.F.5 - Simulations can contain bias derived from the choices of real-world elements that were included or excluded.
AAP-3.F.6 - Simulations are most useful when real-world events are impractical for experiments (e.g., too big, too small, too fast, too slow, too expensive, or too dangerous).
AAP-3.F.7 - Simulations facilitate the formulation and refinement of hypotheses related to the objects or phenomena under consideration.
DAT-2 - Programs can be used to process data, which allows users to discover information and create new knowledge.
DAT-2.D - Extract information from data using a program.
DAT-2.D.6 - Some processes that can be used to extract or modify information from data include the following:
transforming every element of a data set, such as doubling every element in a list, or extracting the parent’s email from every student record
filtering a data set, such as keeping only the positive numbers from a list, or keeping only students who signed up for band from a record of all the students
combining or comparing data in some way, such as adding up a list of numbers, or finding the student who has the highest GPA
visualizing a data set through a chart, graph, or other visual representation
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.
3B-AP-10 - Use and adapt classic algorithms to solve computational problems.