
Control Structures: Selection
Use conditional statements to allow programmes to make decisions based on user input or data.
TL;DR:Selection is how programs make decisions. Using 'if-then-else' logic, students can create programs that respond differently depending on the situation. This is a fundamental concept in NCCA Strand 3, allowing for interactivity and complexity in coding projects.
About This Topic
Selection is how programs make decisions. Using 'if-then-else' logic, students can create programs that respond differently depending on the situation. This is a fundamental concept in NCCA Strand 3, allowing for interactivity and complexity in coding projects.
Whether it is a game character losing a life if their health hits zero, or a website showing a 'Welcome' message only if a user is logged in, selection is everywhere. This topic is best explored through active learning, as it allows students to 'act out' the logic and see the branching paths of a program. Students grasp this concept faster through structured discussion and peer explanation of their decision-making logic.
Key Questions
- How do computers make decisions?
- What is a conditional statement?
- How can selection change the flow of a programme?
Watch Out for These Misconceptions
Common MisconceptionThe 'else' part is always required.
What to Teach Instead
Students often think every 'if' needs an 'else'. Using a simple 'If it's Tuesday, we have PE' example shows that sometimes, if the condition isn't met, the program just does nothing and moves on.
Common MisconceptionComputers can 'guess' what you mean if the condition is vague.
What to Teach Instead
Computers need exact conditions (e.g., 'Score > 10' not 'Score is high'). A 'literal robot' activity where students give vague instructions helps them see why precision in selection is vital.
Active Learning Ideas
See all activities→Role Play
The Logic Gatekeeper
One student acts as a 'gatekeeper' with a set of rules (e.g., 'If you are wearing blue, go left; else, go right'). Other students approach, and the gatekeeper must direct them based on the 'if-then' logic.
Inquiry Circle
Choose Your Own Adventure
In small groups, students write a short 'Choose Your Own Adventure' story on cards. Each card must have a clear 'if' choice that leads to a different outcome. They swap stories and 'play' through the selection paths.
Think-Pair-Share
Real-World If-Then
Students identify three 'if-then' decisions they made this morning (e.g., 'If it's raining, I'll take the bus'). They share these with a partner and then try to write them in a 'coding' format.