Skip to content
Computer Science · Grade 9

Active learning ideas

Conditional Statements (If/Else)

Conditional statements can feel abstract to beginners, so active learning turns theory into tangible problem-solving. Students need to see how different conditions change program behavior, which only happens when they write, test, and debug real code. This hands-on approach builds confidence and reveals patterns that lectures alone cannot.

Ontario Curriculum ExpectationsCS.HS.AP.7CS.HS.CT.8
25–45 minPairs → Whole Class4 activities

Activity 01

Escape Room30 min · Pairs

Pair Programming: Grade Classifier

Pairs write a program that reads a numerical grade and uses if-else chains to output letter grades (A, B, C, etc.). They test with edge cases like 100 or 59, then swap computers to extend with nested checks for pass/fail. Pairs demo one unique feature to the class.

Analyze how 'if-else' structures enable programs to respond to different conditions.

Facilitation TipDuring Pair Programming: Grade Classifier, assign roles explicitly—one student writes while the other observes and asks, 'What happens if the input is exactly 50?' to keep both engaged.

What to look forPresent students with a short code snippet containing an if-else structure and a specific input value. Ask them to predict the output of the program and explain their reasoning step-by-step, focusing on how the condition is evaluated.

RememberApplyAnalyzeRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 02

Escape Room45 min · Small Groups

Small Groups: Choose Your Adventure Game

Groups plan a text-based story with 3-4 decision points using nested if-else. They code in a shared editor, incorporating user inputs for paths like 'left' or 'right'. Groups run peer tests and refine based on unexpected branches.

Design a program that uses conditional logic to guide its execution path.

Facilitation TipFor Choose Your Adventure Game, set a 15-minute timer for brainstorming choices, then pause to share one group’s flowchart so everyone sees how decisions branch.

What to look forProvide students with a scenario, such as a simple grading system (e.g., A, B, C based on score). Ask them to write pseudocode for a program that uses conditional statements to assign the correct grade based on a given score.

RememberApplyAnalyzeRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 03

Escape Room35 min · Whole Class

Whole Class: Conditional Error Hunt

Project buggy code with if-else errors on the board or shared screen. Class votes on fixes in rounds, discussing why conditions fail (e.g., wrong operators). Students code corrections individually then vote on best solutions.

Justify the use of nested conditional statements in complex decision-making scenarios.

Facilitation TipIn Conditional Error Hunt, hand out sticky notes for students to annotate errors directly on printed code, then rotate groups to find one new error each time.

What to look forPose the question: 'When might you choose to use an if-else if-else structure instead of multiple independent if statements? Provide a specific programming example to illustrate your point.'

RememberApplyAnalyzeRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 04

Escape Room25 min · Individual

Individual: FizzBuzz Challenge

Students code a FizzBuzz program: numbers 1-100 print 'Fizz' for multiples of 3, 'Buzz' for 5, 'FizzBuzz' for both, else the number. They add nested conditions for custom rules, test outputs, and submit variations.

Analyze how 'if-else' structures enable programs to respond to different conditions.

Facilitation TipFor FizzBuzz Challenge, provide a 5-minute silent work block before pairing up to compare solutions, reducing rushed or copied answers.

What to look forPresent students with a short code snippet containing an if-else structure and a specific input value. Ask them to predict the output of the program and explain their reasoning step-by-step, focusing on how the condition is evaluated.

RememberApplyAnalyzeRelationship SkillsSelf-Management
Generate Complete Lesson

A few notes on teaching this unit

Start by having students trace code on paper with highlighters to mark which lines execute, because this forces them to slow down and see logic paths. Avoid rushing to syntax; focus on the decision tree first. Research shows that students grasp control flow better when they draw it before coding. Always pair explanations with concrete, relatable examples, like grading or game choices, to ground abstract concepts.

Students will confidently write if/else structures for clear decision points, justify their design choices in simple nested cases, and debug conditional logic errors without prompting. They will explain how conditions control flow and why structure matters in real-world scenarios.


Watch Out for These Misconceptions

  • During Choose Your Adventure Game, watch for students assuming nested ifs are always better than chained if-else. Correction: Assign groups to redesign the same scenario using both styles, then measure code length and readability. Use peer critiques to highlight when chaining reduces indentation issues.


Methods used in this brief