Selection: If, Elif, ElseActivities & Teaching Strategies
Active learning works well here because conditional logic is best understood through immediate feedback and debugging. Students need to see how tiny changes affect program flow, which is hard to grasp from reading alone. Pairing and group work let them test predictions, correct mistakes, and build confidence with real code outcomes.
Learning Objectives
- 1Design a Python program that uses if, elif, and else statements to provide different outputs based on user input.
- 2Analyze the logical conditions within a program to predict its execution path.
- 3Evaluate the effectiveness of selection structures in solving specific programming problems.
- 4Compare the outcomes of programs using simple if statements versus those with if-elif-else chains.
- 5Create nested selection statements to model more complex decision-making processes in a program.
Want a complete lesson plan with these objectives? Generate a Mission →
Pair Programming: Quiz Grader
Pairs write a program that takes a quiz score input and uses if-elif-else to output grades: A for 90+, B for 80-89, etc. They test with various scores, then swap to improve each other's code. End with pairs presenting one edge case.
Prepare & details
Design a program that uses selection to provide different responses based on user input.
Facilitation Tip: During Pair Programming: Quiz Grader, circulate and ask each pair to verbalize the condition they are testing before they run the code.
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: Nested Decision Trees
Groups build a text adventure game with nested if statements for choices like 'left' or 'right' paths, including elif for invalid inputs. They run simulations, record paths taken, and refine for better user experience.
Prepare & details
Evaluate the importance of logical conditions in controlling program flow.
Facilitation Tip: For Small Groups: Nested Decision Trees, provide a blank flowchart template so students can map logic before coding.
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: Code Critique Relay
Project student code snippets with selection errors on the board. Class votes on fixes in a relay: one student suggests indentation change, next tests condition logic. Discuss as a group why the code now works.
Prepare & details
Analyze how nested selection statements mirror complex human decision-making.
Facilitation Tip: In the Whole Class: Code Critique Relay, rotate roles every five minutes to keep all students engaged in spotting and fixing errors.
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: Condition Challenges
Students complete worksheets with buggy code blocks using if-elif-else, such as sorting numbers into categories. They predict outputs, code fixes, and verify by running in Python.
Prepare & details
Design a program that uses selection to provide different responses based on user input.
Facilitation Tip: For Individual: Condition Challenges, give students five minutes to annotate the code with expected outputs before attempting to run it.
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 conditionals as a conversation between program and user. Start with a single if-else to build trust in the structure, then introduce elif as a way to narrow choices, not add more ifs. Emphasize tracing: students should read code aloud like a story, predicting outcomes before executing. Avoid rushing to complex examples; mastering simple chains first prevents later confusion with nested logic.
What to Expect
Students will confidently write if-elif-else chains that match inputs to expected outputs. They will trace conditions step-by-step, explaining why only one branch runs and how indentation controls execution. Programs will run without syntax errors and produce predictable results for varied inputs.
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: Quiz Grader, students often assume each elif opens a new branch, leading to multiple prints. Watch for pairs who test inputs that should satisfy only one condition.
What to Teach Instead
Ask pairs to trace their code on paper first, drawing arrows to show which branch runs for each input before they run it.
Common MisconceptionDuring Whole Class: Code Critique Relay, students forget colons or misalign indentation, treating errors as logic mistakes. Watch for groups who skip syntax fixes and focus only on changing conditions.
What to Teach Instead
Set a three-minute timer for syntax-only debugging rounds where teams fix indentation and colons before discussing logic.
Common MisconceptionDuring Small Groups: Nested Decision Trees, students default to == in all conditions, including ranges. Watch for groups who write if score == 50 instead of if score >= 50.
What to Teach Instead
Display a list of operators on the board and ask each group to justify their choice in one sentence before coding.
Assessment Ideas
After Individual: Condition Challenges, collect each student’s annotated code and ask them to write one sentence explaining why the else clause is necessary for inputs that don’t meet any condition.
During Small Groups: Nested Decision Trees, pause the activity and present a projected code snippet with an if-elif-else chain. Ask each group to predict the output for three different inputs and hold up their answers on mini-whiteboards.
After Whole Class: Code Critique Relay, pose the discussion prompt: 'When might you need elif instead of multiple ifs?' Have students share scenarios and vote on the clearest example before moving to the next task.
Extensions & Scaffolding
- Challenge: Ask students to modify their quiz grader so it also prints the percentage score using elif for grade boundaries (e.g., 80+ = A, 60+ = B).
- Scaffolding: Provide pre-written elif chains with missing conditions or operators, so students fill in the correct comparisons.
- Deeper exploration: Introduce elif with Boolean operators (and, or) to create compound conditions for advanced grading scenarios.
Key Vocabulary
| Selection | A control flow statement that allows a program to execute different blocks of code based on whether a condition is true or false. |
| If statement | Executes a block of code only if a specified condition evaluates to true. |
| Elif statement | Checks another condition if the preceding if or elif condition was false. Stands for 'else if'. |
| Else statement | Executes a block of code if all preceding if and elif conditions in the structure evaluate to false. |
| Boolean expression | An expression that evaluates to either True or False, used as the condition in selection statements. |
Suggested Methodologies
More in Python: From Blocks to Text
Introduction to Python Environment
Students set up and navigate the Python programming environment, understanding basic syntax and execution.
2 methodologies
Variables and Data Types
Students explore how computers store different kinds of information and how to manipulate data using Python syntax.
2 methodologies
Basic Input and Output
Students write Python programs that can interact with the user by taking input and displaying output.
2 methodologies
Arithmetic and String Operations
Students perform mathematical calculations and manipulate text data in Python using operators.
2 methodologies
Iteration: For Loops
Students use 'for' loops to repeat blocks of code a specific number of times or iterate through sequences.
2 methodologies
Ready to teach Selection: If, Elif, Else?
Generate a full mission with everything you need
Generate a Mission