Branching Logic: If-Then-Else DecisionsActivities & Teaching Strategies
Active learning works for branching logic because students need to physically trace and manipulate decision paths to see how conditions control program flow. Moving their bodies and materials to represent 'if-then-else' branches helps them internalize that only one path is taken, not both.
Learning Objectives
- 1Design a simple game or animation using 'if-then-else' statements to control character actions based on user input.
- 2Explain how conditional statements direct the sequence of operations within a program.
- 3Analyze the outcome of a program by tracing the execution path of 'if-then-else' logic with given inputs.
- 4Evaluate the effectiveness of an 'if-then-else' structure in solving a specific problem, such as guiding a character through a maze.
Want a complete lesson plan with these objectives? Generate a Mission →
Pair Programming: Obstacle Course
Students pair up to code a sprite that uses if-then-else to dodge obstacles: if touching red block, turn left; else, go forward. Partners alternate coding and testing, then modify for new conditions. End with a class showcase.
Prepare & details
Explain how conditional statements guide a program's flow.
Facilitation Tip: During Pair Programming: Obstacle Course, circulate and ask each pair to verbally explain their condition and predicted path before testing, using sentence frames like 'When __, the program will __.'
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
Small Groups: Quiz Brancher
Groups build a multiple-choice quiz where correct answers advance with praise, incorrect ones loop back with hints via if-then-else. Test on peers, record scores, and refine logic based on feedback.
Prepare & details
Design a scenario where 'if-then-else' logic is essential for a program's function.
Facilitation Tip: While Small Groups work on Quiz Brancher, provide printed flowcharts so students can mark the executed path with highlighters as they test inputs.
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
Whole Class: Traffic Controller
Project a shared program where class votes on conditions for a traffic light: if timer over 30 seconds, change color; else, stay. Students suggest tweaks live, observing flow changes together.
Prepare & details
Evaluate the impact of changing a condition on a program's outcome.
Facilitation Tip: For Whole Class: Traffic Controller, assign roles clearly—one student controls the condition input, another traces the flowchart, and a third runs the program to verify predictions.
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
Individual: Choice Adventure
Each student codes a story with branching paths: if choose 'left', show cave scene; else, forest. Run through all paths, debug alone, then pair to exchange and play.
Prepare & details
Explain how conditional statements guide a program's flow.
Facilitation Tip: In Individual: Choice Adventure, require students to submit a flowchart before coding to ensure they plan the decision structure first.
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
Teaching This Topic
Teach branching logic by starting with concrete, relatable scenarios students can act out with their bodies or manipulatives. Avoid abstract theory early on; instead, use flowcharts and step-by-step tracing to build understanding. Research suggests that students grasp conditional logic better when they debug misconceptions in real time, so provide immediate feedback during hands-on tasks rather than after full program completion.
What to Expect
Successful learning looks like students confidently explaining which branch executes for given conditions, tracing code step-by-step without skipping steps, and designing multiple scenarios with varied conditions. They should connect conditions to actions and predict outcomes before testing.
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
Watch Out for These Misconceptions
Common MisconceptionDuring Pair Programming: Obstacle Course, watch for students who assume both branches execute simultaneously.
What to Teach Instead
Have pairs physically stand in two lines representing each branch, then mark the executed path with a cone or arrow before running the program to test their prediction.
Common MisconceptionDuring Small Groups: Quiz Brancher, watch for students who only test equality conditions.
What to Teach Instead
Provide a list of varied operators (>, <, =) and require groups to test at least two different operators in their quiz questions before finalizing.
Common MisconceptionDuring Whole Class: Traffic Controller, watch for students who believe the order of conditions doesn’t matter.
What to Teach Instead
Use a flowchart on the board and physically rearrange the 'if-then' blocks to show how moving an 'else' clause changes which action executes.
Assessment Ideas
After Pair Programming: Obstacle Course, give each student a flowchart with two different inputs. Ask them to trace and write the output for each input, explaining which branch was taken and why.
During Small Groups: Quiz Brancher, ask each group to share their 'if-then-else' statement with the class, specifying the condition, 'then' action, and 'else' action for a sample input you provide.
After Whole Class: Traffic Controller, invite students to share their programs in a gallery walk. Ask them to point to the decision point in their code and explain what happens when the condition is true versus false, using sentence starters like 'The condition checks for...' and 'If true, the program does...'
Extensions & Scaffolding
- Challenge students who finish early to add a nested 'if-then-else' condition to their program, such as a character that changes color if it touches one obstacle but shrinks if it touches another.
- For students who struggle, provide pre-written condition blocks with missing values (e.g., 'if __ > 5 then...') so they focus on understanding the structure rather than syntax.
- Allow extra time for students to swap programs with peers and trace each other's logic, writing comments on sticky notes to explain the decision points.
Key Vocabulary
| Conditional Statement | A programming statement that executes a block of code only if a specific condition is true. It allows programs to make decisions. |
| If-Then-Else Logic | A control flow structure where a program checks a condition. If true, it performs one action (then); otherwise, it performs a different action (else). |
| Condition | A statement that can be evaluated as either true or false, used to determine which path a program should take. |
| Boolean Value | A value that can only be true or false, often used as the result of a condition in programming. |
Suggested Methodologies
More in Algorithmic Logic and Sequences
Decomposition and Patterns in Everyday Tasks
Students will break down everyday tasks into small, logical steps to identify recurring patterns in problem solving.
2 methodologies
Sequencing Instructions: Step-by-Step Logic
Students will practice creating precise sequences of instructions for simple tasks, understanding order of operations.
2 methodologies
Loops: Repeating Actions Efficiently
Students will explore how loops (repetition) can simplify code and automate repetitive tasks.
2 methodologies
Debugging Simple Algorithms
Students will identify and correct errors (bugs) in simple algorithms and programs.
2 methodologies
Introduction to Visual Programming Environments
Students will get acquainted with a visual programming environment (e.g., Scratch) and its basic interface.
2 methodologies
Ready to teach Branching Logic: If-Then-Else Decisions?
Generate a full mission with everything you need
Generate a Mission