Skip to content

Conditional Logic: If/Else StatementsActivities & Teaching Strategies

Active learning works well for conditional logic because students need to see branches execute, not just hear about them. Watching code paths play out in real time helps students grasp why only one branch runs, making abstract concepts concrete.

Year 8Technologies4 activities30 min50 min

Learning Objectives

  1. 1Analyze how different conditions alter the execution path of a program.
  2. 2Construct a scenario where an if/else statement is the most appropriate control flow mechanism.
  3. 3Evaluate the impact of incorrect conditional logic on program behavior.
  4. 4Implement if/else statements to create programs that make decisions based on specific criteria.

Want a complete lesson plan with these objectives? Generate a Mission

45 min·Pairs

Pair Programming: Quiz Game Builder

Pairs use a block-based editor to create a quiz with if/else for scoring answers correct or incorrect, adding else for retries. Test with classmates, then swap roles to modify questions. Record scores to discuss condition accuracy.

Prepare & details

Analyze how different conditions alter the execution path of a program.

Facilitation Tip: During Pair Programming: Quiz Game Builder, ask each pair to swap partners after completing one quiz question to share debugging strategies.

Setup: Group tables with puzzle envelopes, optional locked boxes

Materials: Puzzle packets (4-6 per group), Lock boxes or code sheets, Timer (projected), Hint cards

RememberApplyAnalyzeRelationship SkillsSelf-Management
50 min·Small Groups

Small Groups: Debug Challenge Circuit

Provide buggy if/else code snippets for traffic lights or vending machines. Groups trace execution paths on paper first, then code fixes and run tests. Share one fix with the class via demo.

Prepare & details

Construct a scenario where an if/else statement is the most appropriate control flow mechanism.

Facilitation Tip: In Small Groups: Debug Challenge Circuit, require groups to submit a corrected code snippet and a written explanation before moving to the next challenge.

Setup: Group tables with puzzle envelopes, optional locked boxes

Materials: Puzzle packets (4-6 per group), Lock boxes or code sheets, Timer (projected), Hint cards

RememberApplyAnalyzeRelationship SkillsSelf-Management
35 min·Whole Class

Whole Class: Scenario Storyboard

Project a real-world problem like a robot sorter. Class brainstorms conditions, votes on if/else structures, then codes a shared program. Run simulations and vote on improvements.

Prepare & details

Evaluate the impact of incorrect conditional logic on program behavior.

Facilitation Tip: For Whole Class: Scenario Storyboard, assign roles such as 'condition writer,' 'code tester,' and 'path tracer' to ensure participation.

Setup: Group tables with puzzle envelopes, optional locked boxes

Materials: Puzzle packets (4-6 per group), Lock boxes or code sheets, Timer (projected), Hint cards

RememberApplyAnalyzeRelationship SkillsSelf-Management
30 min·Individual

Individual: Personal Decision Tree

Students code an if/else tree for daily choices, like outfit selector based on weather input. Test with varied inputs, note path changes, and reflect in a log.

Prepare & details

Analyze how different conditions alter the execution path of a program.

Setup: Group tables with puzzle envelopes, optional locked boxes

Materials: Puzzle packets (4-6 per group), Lock boxes or code sheets, Timer (projected), Hint cards

RememberApplyAnalyzeRelationship SkillsSelf-Management

Teaching This Topic

Teach conditional logic by having students act as the 'computer' first, physically moving based on conditions written on cards. This builds foundational understanding before transitioning to code. Avoid long lectures about syntax; instead, let errors surface naturally during hands-on work. Research shows students retain logic better when they debug their own flawed conditions.

What to Expect

Students should confidently trace if/else paths for simple conditions and explain why only one branch executes. They should also identify missing conditions or incorrect comparisons that lead to silent failures.

These activities are a starting point. A full mission is the experience.

  • Complete facilitation script with teacher dialogue
  • Printable student materials, ready for class
  • Differentiation strategies for every learner
Generate a Mission

Watch Out for These Misconceptions

Common MisconceptionDuring Pair Programming: Quiz Game Builder, watch for students who assume both branches of an if/else statement always run.

What to Teach Instead

Have pairs add print statements at the start of each branch and run multiple test cases to observe that only one branch executes per input.

Common MisconceptionDuring Small Groups: Debug Challenge Circuit, watch for students who confuse assignment (=) with equality (==) in conditions.

What to Teach Instead

Ask groups to manually test their conditions with sample inputs and document why == must be used for comparisons, not =.

Common MisconceptionDuring Whole Class: Scenario Storyboard, watch for students who think else covers all unmet conditions automatically.

What to Teach Instead

Require groups to draft conditions for all possible outcomes and identify any gaps that leave cases unaddressed.

Assessment Ideas

Exit Ticket

After Pair Programming: Quiz Game Builder, ask students to write an if/else statement for the scenario 'If the light is green, then the car moves, otherwise the car stops.' Then ask them to trace the output when the light is red.

Quick Check

During Small Groups: Debug Challenge Circuit, circulate and ask groups to predict the output of a given block-based if/else snippet for two inputs, such as 'If age >= 13, then display 'Teen', else display 'Child' with inputs 12 and 15.

Discussion Prompt

After Whole Class: Scenario Storyboard, pose the following: 'Your program sorts fruits into bins. How would you write an if/else statement to place apples in the fruit bin and oranges in the fruit bin? What if you only have one bin for both?' Facilitate a brief discussion on inclusive conditions.

Extensions & Scaffolding

  • Challenge students to add nested if/else statements to their quiz game, such as bonus questions that only appear if the first answer is correct.
  • For students who struggle, provide partially completed code with missing conditions or operators for them to fill in.
  • Give advanced students a scenario with contradictory conditions to resolve, such as 'If temperature > 30°C, then display 'Hot' else if temperature < 10°C, then display 'Cold' else display 'Mild'.'

Key Vocabulary

Conditional LogicA programming concept that allows a program to execute different blocks of code based on whether certain conditions are true or false.
If/Else StatementA control flow structure that executes one block of code if a specified condition is true, and an alternative block of code if the condition is false.
ConditionA statement that evaluates to either true or false, determining which path of execution a program will take.
BooleanA data type that can only have one of two values: true or false. Conditions in if/else statements typically evaluate to a boolean value.

Ready to teach Conditional Logic: If/Else Statements?

Generate a full mission with everything you need

Generate a Mission