Skip to content
Computing · Year 6

Active learning ideas

Changing States with Variables

Active learning works well for this topic because students need to observe how variables directly alter program behavior in real time. By manipulating variables in games and animations, they build a concrete understanding of state changes that static examples cannot provide.

National Curriculum Attainment TargetsKS2: Computing - Programming and AlgorithmsKS2: Computing - Computational Thinking
25–45 minPairs → Whole Class4 activities

Activity 01

Problem-Based Learning35 min · Pairs

Pair Programming: State Changer Challenge

Pairs use Scratch to create a sprite whose appearance and movement change with a variable updated by keyboard input. They set an initial value, add code to increment it, then test across multiple states like 'walking' or 'jumping'. Pairs swap projects to predict and verify changes.

Analyze how changing a variable's value impacts the flow of a simple animation.

Facilitation TipDuring Pair Programming: State Changer Challenge, circulate to ensure both partners take turns coding and discussing how variable changes affect the animation.

What to look forProvide students with a short Scratch project where a variable controls the size of a sprite. Ask them to write: 1. The name of the variable. 2. How changing the variable's value affects the sprite. 3. One suggestion for another sprite property that could be controlled by a variable.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Problem-Based Learning45 min · Small Groups

Small Groups: Level Switch Debugger

Provide groups with a buggy game code where variable updates fail to switch levels. Groups predict fixes, implement changes collaboratively, and demo their working version to the class. Include variables for score thresholds and scene transitions.

Predict the outcome of a program if a variable is updated incorrectly.

Facilitation TipIn Small Groups: Level Switch Debugger, assign each group a different bug to isolate, so they practice tracing variable influence across code blocks.

What to look forDisplay a code snippet showing a variable being updated and then used in a conditional statement (e.g., 'if score > 10 then...'). Ask students to hold up fingers indicating the value of the variable after the update, or verbally state the outcome of the conditional. Repeat with different variable values.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Problem-Based Learning25 min · Whole Class

Whole Class: Live Prediction Demo

Project a simple animation code with a key variable. Class predicts outcomes of updates shown step-by-step, then a volunteer codes the change live. Discuss matches between predictions and results, repeating with student-suggested alterations.

Construct a sequence of code that uses a variable to switch between different game levels.

Facilitation TipFor the Whole Class: Live Prediction Demo, invite students to explain their predictions before revealing outcomes to reveal hidden misunderstandings.

What to look forPose the scenario: 'Imagine a game where a variable called 'fuel' starts at 100. If the player flies too fast, the fuel decreases by 5 every second. If they fly too slow, it increases by 2 every second. What happens if the player never flies fast or slow?' Encourage students to discuss the potential outcomes and how the variable's behavior dictates the game's state.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Problem-Based Learning30 min · Individual

Individual: Variable Animation Builder

Each student builds an animation sequence where a variable controls states like colour cycles or speed ramps. They document predictions before running, then adjust based on tests. Share one successful tweak with a partner.

Analyze how changing a variable's value impacts the flow of a simple animation.

Facilitation TipDuring Individual: Variable Animation Builder, provide a checklist of required variable-driven behaviors to guide self-assessment of their work.

What to look forProvide students with a short Scratch project where a variable controls the size of a sprite. Ask them to write: 1. The name of the variable. 2. How changing the variable's value affects the sprite. 3. One suggestion for another sprite property that could be controlled by a variable.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Approach this topic by starting with physical metaphors, like holding up cups labeled with variable names to show how their contents change. Avoid abstract explanations without visual or interactive examples, as students often struggle to grasp scope without concrete demonstrations. Research suggests students benefit from seeing the same variable used in multiple contexts, so reusing examples across activities strengthens understanding.

Successful learning looks like students confidently predicting how variable updates will change program behavior and explaining the connection between updates and program state. They should also troubleshoot incorrect updates without relying solely on teacher intervention.


Watch Out for These Misconceptions

  • During Pair Programming: State Changer Challenge, watch for students who assume variables cannot be updated more than once.

    Use the activity’s counter example to show repeated updates. Ask partners to test the counter by running the animation multiple times and observing how the variable’s value and the sprite’s behavior change each time.

  • During Small Groups: Level Switch Debugger, watch for students who think changing one variable affects all sprites equally.

    Have groups isolate one variable and trace its effect on a single sprite using the debugger’s step-through feature. Discuss why other sprites remain unchanged when the variable only targets one.

  • During Individual: Variable Animation Builder, watch for students who believe variable updates always break the program.

    Provide a set of safe, pre-tested code blocks they can modify. Encourage them to make small, intentional changes and test after each one, normalizing the idea that updates can enhance functionality when done correctly.


Methods used in this brief