Unit 5 Lesson 11: While Loops Students will be able to: � Explain that a while loop continues to run while a boolean condition remains true. � Translate a real-life activity with repeated components into a form that could be represented by a while loop. � Analyze a while loop to determine if the initial condition will be met, how many times the loop will run, and if the loop will ever terminate. � Write programs that use while loops in a variety of contexts.
While Loops � while loops are the most primitive type of loop. � The for loop is just a more specific case of a while loop. � while loops repeat a set of steps until a certain condition is met. � Like conditional statements, while loops use boolean expressions to determine if they will run and how many times. � One of the biggest problems a programmer can run into with a while loop is to create an infinite loop. � There a couple different defensive programming strategies introduced in this lesson to help prevent infinite loops.
U 5 L 11 Vocab � Iterate - To repeat in order to achieve, or get closer to, a desired goal. � while loop - a programming construct used to repeat a set of commands (loop) as long as (while) a boolean condition is true.
U 5 L 11 Prompt: � Follow the "instructions" in the diagram and then wait quietly.