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

Loops

Ninth graders learn loops — a for loop repeats a set number of times; a while loop repeats until a condition becomes false. They match loop terms to meanings, then write loops to avoid repeating themselves.

Grade 9Loops (for & while)55 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…

  • ✓Tell for from while.
  • ✓Use range().
  • ✓Avoid an infinite loop.
  • ✓Replace repetition with a loop.
Essential Question

How do loops let a program repeat work without copy-paste?

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

Match the Loop Term

Project this and match each loop term to its meaning — tap the term, then tap the meaning.

🔄 Match each loop term to its meaningTry it
Term
Meaning
Now tap the meaning!
The Lesson · Use → Modify → Create (a coding progression with Unplugged practice)

55 minutes, five moves

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

1

Hook — Say It 10 Times

6 min

How would you print a word ten times without 10 lines?

👩‍🏫 Teacher Moves

  • Show 10 copy-pasted lines.
  • Ask for a shorter way.
  • Set the goal.

🎒 Student Actions

  • Look.
  • Guess.
  • Get ready.
2

Use — Loops

13 min

Students use loops.

👩‍🏫 Teacher Moves

  • Send students to Match the Loop Term.
  • Match each one.
  • Note for vs while.

🎒 Student Actions

  • Match.
  • Say.
  • Note it.
3

Modify — Change the Count

14 min

Students modify.

👩‍🏫 Teacher Moves

  • Change range(5) to range(10).
  • Convert a for to a while.
  • Spot an infinite loop risk.

🎒 Student Actions

  • Change.
  • Convert.
  • Spot.
4

Create — Loop It

15 min

Students create.

👩‍🏫 Teacher Moves

  • Replace 5 repeated lines with a loop.
  • Loop over a list.
  • Test the output.

🎒 Student Actions

  • Replace.
  • Loop.
  • Test.
5

Reflect — Reflect

7 min

Students close.

👩‍🏫 Teacher Moves

  • Say when to use for vs while.
  • Say what causes an infinite loop.
  • Complete the exit ticket.

🎒 Student Actions

  • Say it.
  • Say.
  • 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-15

Iteratively develop programs using loops.

CSTA
3A-AP-16

Combine control structures to express ideas in code.

CSTA
3A-AP-21

Evaluate and refine computational artifacts.

ISTE
5 Computational Thinker

Automate repetition to solve problems.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • Clap-count a loop.
  • Frame: repeat N times.
  • Trace a loop by hand.

Support & Access

IEP / 504
  • Start with for + range.
  • Small counts (3).
  • Use a counter chart.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Nest two loops.
  • Use while with user input.
  • Loop with a break condition.
Materials

What to gather

  • 📽️Screen / board
  • 🔄Loop term cards
  • 💻Match the Loop Term
  • 🐍Python / editor
  • 📓Notebooks
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

loopcode that repeatsfor looprepeats a set number of timeswhile looprepeats until a condition is falserange()a sequence of numbers to loop overiterationone pass through the loopcountera variable that tracks repeatsinfinite loopa loop that never ends (a bug)bodythe code that repeats inside a loop
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 how many times to repeat.
QUESTION 2
When do you use a while loop?
When you repeat until a condition is false.
QUESTION 3
What is an infinite loop?
A loop that never stops — usually a bug.

Reflect: loops.

Have students rewrite 5 repeated lines as one loop. A printable loops worksheet is in the Computer Science 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.

🃏 CS Loops for and while (Grade 9)Flip
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.

📝 CS Loops for and while (Grade 9)Quiz
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.

🖨️ CS Loops for and while (Grade 9)Print
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: body, counter, for loop, infinite loop, iteration, loop, range(), while loop
  1. repeats until a condition is false
  2. a sequence of numbers to loop over
  3. a loop that never ends (a bug)
  4. the code that repeats inside a loop
  5. code that repeats
  6. one pass through the loop
  7. a variable that tracks repeats
  8. repeats a set number of times

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) while loop · 2) range() · 3) infinite loop · 4) body · 5) loop · 6) iteration · 7) counter · 8) for loop
Part B: 1) When you know how many times to repeat. 2) When you repeat until a condition is false. 3) A loop that never stops — usually a bug.