Everything you need before the bell rings
Learning Objectives
Students will be able to…
- ✓Define scope.
- ✓Tell local from global.
- ✓Avoid scope bugs.
- ✓Trace scope.
Why does a variable sometimes work in one place but not another?
Variable Scope
Project each one and have students answer about variable scope.
50 minutes, five moves
Tap any phase to open the teacher moves and student actions.
Hook — Not Found
Why might a variable give a "not defined" error in one spot?
👩🏫 Teacher Moves
- Pose the question.
- Share ideas.
- Set the goal.
🎒 Student Actions
- Think.
- Share.
- Get ready.
Use — Scope
Students learn.
👩🏫 Teacher Moves
- Send students to Variable Scope.
- Note local vs global.
- Note where each works.
🎒 Student Actions
- Answer.
- Note it.
- Note it.
Modify — Trace It
Students practice.
👩🏫 Teacher Moves
- Spot a local variable.
- Spot a global one.
- Predict where each works.
🎒 Student Actions
- Local.
- Global.
- Predict.
Create — Create
Students apply.
👩🏫 Teacher Moves
- Write a function with a local variable.
- Try to use it outside.
- Fix the scope.
🎒 Student Actions
- Write.
- Test.
- Fix.
Reflect — Reflect
Students close.
👩🏫 Teacher Moves
- What is scope?
- Where does a local variable work?
- Complete the exit ticket.
🎒 Student Actions
- Say it.
- Say it.
- Complete the exit ticket.
Built to the standards you report on
Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students.
Understand variable scope.
Document variable use.
Debug scope errors.
Reason about program state.
One lesson, every learner
Multilingual Learners
- Scope diagram.
- Frame: "a local variable works ___."
- Trace a small program.
Support & Access
- Local vs global only.
- Use a diagram.
- Use examples.
Stretch & Extend
- Explore the global keyword.
- Nest function scopes.
- Debug a scope bug.
What to gather
- 📽️Screen / board
- 🔍Scope diagram
- 💻Variable Scope
- 💻Code editor
- 📓Notebooks
- 🎫Exit-ticket slips
Key terms — hover for a quick definition
Exit Ticket
Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students.
Reflect: variable scope.
Have students trace local vs global scope in a program. A printable scope sheet is in the CS library.
Study the key terms
Tap a card to flip it, then rate whether you knew it. Built from this lesson’s vocabulary.
Nice work!
Check your understanding
A quick self-check with instant feedback, drawn from this lesson’s key terms.
Nice work!
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.
Part A · Write the word that matches each meaning
- where a variable is usable
- a program error
- across the whole program
- inside a function only
- a named value
- a reusable code block
- where names live
- able to be used
Part B · Show what you learned
- What is variable scope?
- Where does a local variable work?
- Where does a global variable work?
Part B: 1) Where in the code a variable can be used. 2) Only inside its function. 3) Across the whole program.