Warm Up (5 minutes)
Activity (45 minutes)
Wrap Up (20 minutes)
New Notes
i++ means to add one more to the variable and continue
i-- means to subtract one from the variable and continue
For Loops and While Loops - Fill in the missing information
Iteration: a repetitive portion of an algorithm which repeats a specified number of times or until a given condition is met.
Infinite loop: occurs when the ending condition will never evaluate to true. In other words, the Boolean expression will never evaluate to false.
For Loop: Uses a boolean condition to repeatedly run a block of code. If it is true it runs the block of code contained within it. This process of checking the condition and running the block of code is repeated as long as the Boolean condition remains true. Once the Boolean expression becomes false it will stop.
for(var i=0; i<3; i++){
… do something
}
While Loop: Condenses the parts of a while loop into a shorter statement. Similar to the while loop, once the Boolean expression becomes false, the loop ends.
var count = 0;
while(count < 3){
… do something
count++;
}
Students begin the lesson by discussing the purpose of loops before completing the unplugged activity. This activity involves moving a "robot" around a game board while practicing tracing blocks of code by hand. To conclude, the lesson is wrapped up with a vocabulary discussion and a video.
Students practice using the for loop in order to repeatedly run pieces of code. The lesson begins with a quick investigation of an app that flips coins. After that code investigation students complete another investigation with an app that uses loops to update screen elements.
Students are introduced to the concept of loops through a robot maze activity. This unplugged lessons provides students a physical mental model they will be able to use when they start programming with loops in the subsequent lessons.
This lesson is students primary opportunity to get hands on with loops in code prior to the Practice 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.
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.K.1 - Iteration statements change the sequential flow of control by repeating a set of statements zero or more times, until a stopping condition is met.
AAP-2.K.4 - In REPEAT UNTIL(condition) iteration, an infinite loop occurs when the ending condition will never evaluate to true.
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.
AAP-3.F.8 - Random number generators can be used to simulate the variability that exists in the real world.
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
3A-AP-15 - Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance and explain the benefits and drawbacks of choices made.
3B-AP-23 - Evaluate key qualities of a program through a process such as a code review.
DA - Data & Analysis
3A-DA-12 - Create computational models that represent the relationships among different elements of data collected from a phenomenon or process.