Home›Lesson Plans›Computer Science›Programming · Grade 9

For vs While Loops

Ninth graders learn when to use each kind of loop — a FOR loop when you know how many times to repeat (or are looping over a collection), and a WHILE loop when you repeat until a condition changes. They check the ideas, then pick the right loop.

Grade 9For vs While Loops55 minutes1 class periodCSTA / ISTEExplicit teaching4 StandardsCSTA
Start the Lesson
Assign or share this lesson

Copy link works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment.

Lesson at a Glance

Everything you need before the bell rings

Learning Objectives

Students will be able to…

  • ✓Use a for loop.
  • ✓Use a while loop.
  • ✓Avoid infinite loops.
  • ✓Pick the right one.
Essential Question

Which loop should you use — and when?

0
Lesson Phases
0
Vocabulary Terms
0
Standards Aligned
0
Interactive Task
Check It · Interactive

For vs While Loops

Project each one and have students answer about choosing a loop.

🔁 Choose the right loopTry it
Answer each question about for vs while loops.
The Lesson · Explicit teaching

55 minutes, five moves

Tap any phase to open the teacher moves and student actions.

1

Hook — Which Loop?

6 min

You want to repeat something — how do you decide which loop to use?

👩‍🏫 Teacher Moves

  • Pose the question.
  • Share ideas.
  • Set the goal.

🎒 Student Actions

  • Think.
  • Share.
  • Get ready.
2

Use — For vs While

13 min

Students learn.

👩‍🏫 Teacher Moves

  • Send students to For vs While Loops.
  • Note for = known count.
  • Note while = until a condition.

🎒 Student Actions

  • Answer.
  • Note it.
  • Note it.
3

Modify — Use It

14 min

Students practice.

👩‍🏫 Teacher Moves

  • Write a for loop.
  • Write a while loop.
  • Add a stopping condition.

🎒 Student Actions

  • For.
  • While.
  • Stop.
4

Create — Create

15 min

Students apply.

👩‍🏫 Teacher Moves

  • Pick a loop for a task.
  • Write it.
  • Avoid an infinite loop.

🎒 Student Actions

  • Pick.
  • Write.
  • Check.
5

Reflect — Reflect

7 min

Students close.

👩‍🏫 Teacher Moves

  • When do you use a for loop?
  • When a while loop?
  • Complete the exit ticket.

🎒 Student Actions

  • Say it.
  • Say it.
  • Complete the exit ticket.
Standards Alignment

Built to the standards you report on

Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students.

CSTA
3A-AP-14

Use for and while loops.

CSTA
3A-AP-15

Justify the choice of loop.

CSTA
3A-AP-17

Test and debug loops.

ISTE
5c

Reason about repetition.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • For/while example cards.
  • Frame: "I use for when ___."
  • Trace each loop.

Support & Access

IEP / 504
  • Focus on for loops.
  • Use a template.
  • Count repeats.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Convert for to while.
  • Add a break.
  • Avoid off-by-one errors.
Materials

What to gather

  • 📽️Screen / board
  • 🔁Loop cards
  • 💻For vs While Loops
  • 💻Python
  • 📓Notebooks
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

for looprepeats a known number of timeswhile looprepeats until a condition changesconditiona true/false testiterationone pass of a loopinfinite loopa loop that never stopscollectiona group to loop overcountertracks loop progressbreakexit a loop early
Evaluate

Exit Ticket

Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students.

QUESTION 1
When do you use a for loop?
When you know the count or loop over a collection.
QUESTION 2
When do you use a while loop?
When you repeat until a condition changes.
QUESTION 3
What is an infinite loop?
A loop that never stops — usually a bug.

Reflect: for vs while loops.

Have students pick and write the right loop for a task. A printable loop sheet is in the CS library.

Study · Flashcards

Study the key terms

Tap a card to flip it, then rate whether you knew it. Built from this lesson’s vocabulary.

🃏 For vs While LoopsFlip
Card 1
Term
Tap to flip →
Meaning
0

Nice work!

Practice · Quiz

Check your understanding

A quick self-check with instant feedback, drawn from this lesson’s key terms.

📝 For vs While LoopsQuiz
Score: 0
1 / 6
Question 1
0%

Nice work!

Practice · Worksheet

Printable worksheet

A print-and-go review sheet with a built-in answer key. Tap “Show answer key” to reveal answers, or print the clean version for students.

🖨️ For vs While LoopsPrint
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: break, collection, condition, counter, for loop, infinite loop, iteration, while loop
  1. repeats a known number of times
  2. a true/false test
  3. a loop that never stops
  4. exit a loop early
  5. a group to loop over
  6. one pass of a loop
  7. repeats until a condition changes
  8. tracks loop progress

Part B · Show what you learned

  1. When do you use a for loop?
  2. When do you use a while loop?
  3. What is an infinite loop?
Answer key — Part A: 1) for loop · 2) condition · 3) infinite loop · 4) break · 5) collection · 6) iteration · 7) while loop · 8) counter
Part B: 1) When you know the count or loop over a collection. 2) When you repeat until a condition changes. 3) A loop that never stops — usually a bug.