AP Computer Science A · Lesson 2.8 · Unit 2 · CED topic 2.7

while loops

Name:   Date:  

1 Why this lesson matters

Read the opening paragraph and the "Required content" box on the lesson page. In your own words, explain each objective below.

7.A. Identify when an iterative process is required to achieve a desired result.

7.B. Develop code to represent iterative processes using while loops and determine the result of these processes.

2 Iteration

Read this section. In your own words, summarize the main idea.

3 The while statement

Read this section. In your own words, summarize the main idea.

Initialize
Test
Update

4 Loops that run zero times, and loops that never end

Read this section. In your own words, summarize the main idea.

5 Off-by-one errors

Read this section. In your own words, summarize the main idea.

6 Worked example

Read the "Worked example" box. Then, without looking back, try writing your own answer below.

Trace the loop and give the output.

7 Exam focus: avoid this mistake

Read the "Exam focus" box, then restate it in your own words.

8 Sum it up

In two or three sentences, explain this lesson's main idea to someone who has not read it.