Study Guide Instructor view
Selection
Teaching notes for Lesson 5.4, with controls for presenting it.
Keep this page on your own screen. Share only the lesson window. The lesson window holds no teaching notes, so sharing it cannot show them.
Presenting
- Open the lesson in its own window and share that window, not this one.
- Use Next and Previous here, or the lesson’s own, to move through the lesson. Next reveals one thing at a time: the next idea, or the answer to the question on screen, then the next step. Previous takes the last reveal back. The line below says what is on screen and what Next will show.
- Reveal hints and answers when the class is ready, and reset a demonstration before using it again.
The controls need JavaScript and a browser that supports BroadcastChannel. Without them, open the lesson in presentation mode and use its own controls.
The two windows talk to each other only inside this browser, on this device. Nothing is sent to a server, and no account is needed. A second device (a phone or another tablet) cannot follow the lesson window yet.
Now on the lesson window
- On screen
- Next teaching point
Guidance for this point
Lesson plan
- Level
- Intermediate
- Time
- About 75 minutes; the steps below add up to 75
Pupils start from a rule an attendant could follow (a height check at a water slide) and discover that a program needs to carry out some lines only sometimes. They then meet IF without ELSE, IF with ELSE and compound conditions, nested IF for three outcomes, CASE for a list of exact values, and finally debug a program in which two separate IF statements both fire. The most useful teaching move throughout is to trace edge values (500, 15, 16, 40) on the board, since nearly every misconception shows up there.
Objectives
- Explain what selection is and why programs need it
- Write and follow IF … THEN … ENDIF and IF … THEN … ELSE … ENDIF, with conditions built from relational and logical operators
- Write and trace nested IF statements of up to three levels
- Write and trace CASE … OTHERWISE … ENDCASE
- Choose between IF and CASE for a given problem and justify the choice
- Spot and correct mistakes in selection statements
Before the lesson
- Mini whiteboards, one per pupil, for predictions and trace answers.
- Copy each program onto the board before the lesson so that you can trace with the pen: the discount, the ride, the entry price, the grade calculator and the menu CASE.
- A set of four index cards labelled 620, 500, 480 and 75 for quickly choosing test values.
- Optional: coloured pens, one colour for the path taken through a nested IF and another for the paths skipped.
Steps
Introduction Opening
On the lesson window now
On screen: the lesson’s title, module and number; Next adds its objectives and key terms, as the lesson page lists them; Next again begins the first step.
Objectives on screen
- Explain what selection is and why programs need it
- Write and follow IF … THEN … ENDIF and IF … THEN … ELSE … ENDIF, with conditions built from relational and logical operators
- Write and trace nested IF statements of up to three levels
- Write and trace CASE … OTHERWISE … ENDCASE
- Choose between IF and CASE for a given problem and justify the choice
- Spot and correct mistakes in selection statements
Purpose: Pupils start from a rule an attendant could follow (a height check at a water slide) and discover that a program needs to carry out some lines only sometimes. They then meet IF without ELSE, IF with ELSE and compound conditions, nested IF for three outcomes, CASE for a list of exact values, and finally debug a program in which two separate IF statements both fire. The most useful teaching move throughout is to trace edge values (500, 15, 16, 40) on the board, since nearly every misconception shows up there.
1. A rule with a choice in it Think 5 min
On the lesson window now
Purpose: Pupils turn an everyday rule into check and action, so that selection is met as a decision before IF is named.
Ask
- What is checked, and what happens in each case?
- Can both actions happen for the same rider?
Responses to expect
- Is the height at least 120 cm? Yes: the fast slide. No: the small slide
- Only one happens
Misconceptions to challenge
- A learner may believe: “Each rider gets both slides, one after the other.” Respond: Ask what the attendant does with a rider who is shorter than 120 cm. One check, one of two actions.
Checking understanding: Pupils write the rule on a mini whiteboard; scan for answers that name a check and two outcomes.
Depending on the answers
- If pupils write only the check: ask what the attendant does afterwards in each case, and write both outcomes beside the check.
English as an additional language
- Check at least and tall enough; show a height marker by the slide.
Discussion pause: Thirty seconds of silent thinking, then pairs write the rule as a sentence beginning If.
In the lesson window
- Think it through: Write the attendant’s rule in a form a computer could follow: what is checked, and what happens in each case?
2. Doing something only sometimes Predict 11 min
On the lesson window now
Purpose: Pupils predict a discount program for 620 and for exactly 500, then trace three runs, so that a false condition is met as skipping, not stopping.
Ask
- What is the output when Total is 620? When it is 500?
- Which line always runs, whatever the condition?
- What happens when the condition is false and there is no ELSE?
Responses to expect
- 570 and 500
- OUTPUT, because it is after ENDIF
- The guarded lines are skipped
Misconceptions to challenge
- A learner may believe: “500 gets the discount because it is not more than 500.” Respond: Read the symbol: > is strictly greater. Is 500 greater than 500?
- A learner may believe: “A false condition stops the program.” Respond: Look at the 480 row: the program still outputs a total.
- A learner may believe: “The OUTPUT is part of the IF.” Respond: It is after ENDIF, so it is outside the IF and always runs; indentation shows what belongs inside.
On the board or with the pen
- Trace 620, 500 and 480 as three rows (Total, Is Total > 500?, OUTPUT); draw an arrow that jumps over the guarded line for the false cases.
What learners should notice
- Only one row of the trace changes the total.
Checking understanding: The false-no-else question: stopping and carrying out anyway are the two wrong options, and each is rebutted by the trace rows.
Depending on the answers
- If pupils say 500 gets the discount: put 500 into the condition on the board and ask them to say it aloud: is 500 greater than 500?
- If pupils are secure: ask them to change the program so that 500 is also discounted: which symbol changes?
Support
- Give the trace table with the first row filled in as a model.
English as an additional language
- Check skipped and guarded; mime jumping over a line.
In the lesson window
- Think it through: Predict the output when Total is 620, and when Total is 500. Explain what the IF line decides.
- Check your understanding: In the discount program, what happens when the condition is false and there is no ELSE?
3. Two ways to go Discover 11 min
On the lesson window now
Purpose: Pupils work out when Try again appears and how ELSE differs from a second IF, then trace a compound AND condition for a visitor who passes one test and fails the other.
Ask
- When does Try again appear?
- How is ELSE different from a second IF testing that the guess is wrong?
- A visitor is 125 cm tall and 7 years old: what does the ride program output?
Responses to expect
- Whenever Guess is not 7
- ELSE has no condition of its own
- Sorry, not this ride, because Age >= 8 is false
Misconceptions to challenge
- A learner may believe: “ELSE needs its own condition, such as ELSE Guess <> Target.” Respond: ELSE means otherwise: whatever the IF's condition did not catch. It never has a condition.
- A learner may believe: “= in IF Score = 10 stores 10 in Score.” Respond: In a condition = asks whether they are equal; storing uses the arrow.
- A learner may believe: “With AND, passing one test is enough to enter.” Respond: AND needs both tests true. Ask which test the visitor fails and what that does to the whole condition.
- A learner may believe: “Nothing is output when the tests give mixed results.” Respond: The IF has an ELSE, so exactly one of the two OUTPUT lines runs each time.
On the board or with the pen
- Draw the ride condition as two boxes joined by AND; write TRUE under Height >= 120 and FALSE under Age >= 8, then FALSE under the whole condition.
Checking understanding: The ride-trace question: three options cover the three typical errors (reading only the first test, thinking nothing runs, and the correct AND reading).
Depending on the answers
- If pupils choose Welcome aboard: ask them to evaluate each side of AND separately and combine them as in the AND gate.
- If pupils choose Nothing: ask which OUTPUT line runs when a condition is false.
Stretch
- Change the ride condition to use OR. Which of the four height and age combinations now get a welcome?
English as an additional language
- Check otherwise and compound; read the ride condition aloud as: tall enough and old enough.
In the lesson window
- Think it through: When does “Try again” appear? Describe, in your own words, how ELSE differs from a second IF that tests whether the guess is wrong.
- Check your understanding: A visitor is 125 cm tall and 7 years old. What does the ride program output?
4. Choices inside choices Discover 17 min
On the lesson window now
Purpose: Pupils plan three outcomes from two-way choices in words, follow a worked example to see why the second test can be shorter, then trace and reorder a grade calculator.
Ask
- How could two-way choices decide between three outcomes?
- What does the entry-price program output for age 16?
- In the reversed grade calculator, what does 75 get?
Responses to expect
- First is the age under 5? Then, for the rest, is it 15 or under?
- 700
- Pass, because 75 is at least 40 and the first true test decides
Misconceptions to challenge
- A learner may believe: “A nested IF needs one IF for each outcome.” Respond: Three outcomes need two decisions; the last outcome is whatever remains.
- A learner may believe: “In the inner IF, you must test Age >= 5 again.” Respond: Anyone reaching the ELSE is already at least 5, so the inner test only needs Age <= 15.
- A learner may believe: “More than one block of a nested IF can run.” Respond: Only one block runs: once a THEN has run, the ELSEs inside it are never reached.
- A learner may believe: “The order of the tests does not matter.” Respond: Trace 75 through the reversed order: it matches Mark >= 40 first and stops there. Test the most demanding group first.
On the board or with the pen
- Draw the entry-price program with the pen and trace ages 4, 5, 15 and 16 in a different colour each, showing the path taken. Then redraw the grade calculator beside the reversed version and trace 75 through both.
Follow-up questions
- How many IF statements and ENDIFs does the grade calculator need?
Checking understanding: The age-sixteen check shows who can follow nested decisions from the outside in; the grade-trace table (empty cells for tests never reached) shows who understands that the first true test decides. The reversed-order question catches pupils who think order is irrelevant.
Depending on the answers
- If pupils choose 400 for age 16: ask them to read the inner condition aloud with 16 in it: is 16 less than or equal to 15?
- If pupils leave a cell in the grade table filled when it should be empty: ask whether the test is ever reached once an earlier test is true.
- If the class is secure: ask them to add a Grade A for 90 or more and say where the new test goes.
Support
- Give the age-16 trace with the first inner decision completed.
Stretch
- The syllabus limits nesting to three levels. Rewrite the grade calculator with only one IF per level and say how many levels it uses.
English as an additional language
- Check nested as one inside another; use two boxes, one inside the other, drawn on the board.
In the lesson window
- Think it through: How could you use two-way choices to decide between three outcomes? Describe your plan in words before you write any pseudocode.
- Check your understanding: What does the entry-price program output for a visitor aged 16?
- Apply it: A programmer rewrites the grade calculator and tests Mark >= 40 first (with Pass in its THEN block), then Mark >= 50, then Mark >= 70, nesting each in the ELSE of the one before. What does a pupil with 75 now get?
5. Choosing from a list Predict 12 min
On the lesson window now
Purpose: Pupils predict a CASE menu program for 3 and for 7, trace four runs, and decide when CASE is the clearest fit and when IF is.
Ask
- What is the output for 3, and for 7?
- What is OTHERWISE for?
- Which statement fits a program that turns day numbers 1 to 7 into names?
Responses to expect
- Salad and No such item
- It catches every value not listed
- CASE OF DayNumber with an OTHERWISE
Misconceptions to challenge
- A learner may believe: “CASE can test a range such as 50 to 69.” Respond: A CASE branch holds one exact value; ranges are a job for IF.
- A learner may believe: “Without OTHERWISE, an unlisted value causes an error.” Respond: Nothing happens; OTHERWISE is how you catch the rest.
- A learner may believe: “A single IF can name seven different days.” Respond: A single IF splits into two blocks; it cannot name seven.
- A learner may believe: “A nested IF cannot do this job.” Respond: It can; point out that CASE is clearer for a list of exact values and the syllabus advises it.
On the board or with the pen
- Write the menu program with the pen and mark with a tick which line runs for 1, 3, 7 and 0.
Checking understanding: The days-of-week question is about the clearest tool, not the only one: the nested IF option is a working but clumsier choice, so listen for pupils who say it would work and then give a reason for CASE.
Depending on the answers
- If pupils choose the nested IF: ask them to count how many tests the nested IF needs for seven days, and compare with the CASE list.
- If pupils are secure: ask which of IF or CASE would you use for a mark of 50 to 69, and why.
Support
- Show the CASE and an equivalent IF chain side by side.
English as an additional language
- Check exact value and catches; point to each line as the value matches.
In the lesson window
- Think it through: Predict the output for Choice = 3, and for Choice = 7. How does this program differ from three separate IF statements?
- Apply it: A program turns a day number from 1 to 7 into the name of the day (1 is Monday, 2 is Tuesday and so on) and says “Invalid day” for any other number. Which selection statement is the clearest fit?
6. Finding the fault Apply 11 min
On the lesson window now
Purpose: Pupils find why two separate IF statements both fire for a mark of 75, choose a repair, and write a three-outcome program of their own.
Ask
- A pupil scores 75: what does the program output, and what is wrong?
- Which change gives exactly one word for every mark?
- Write the temperature program: how many IF statements, and why?
Responses to expect
- Pass and Distinction
- Nest Pass inside the ELSE of the Distinction test
- Two nested IFs for three outcomes
Misconceptions to challenge
- A learner may believe: “Swapping the order of two separate IFs fixes the fault.” Respond: 75 is still true for both, so both words appear, in the other order. The second test has to depend on the first.
- A learner may believe: “Changing the second condition to Mark > 70 fixes it.” Respond: 75 is still greater than 70 and than 50. Only one block should be allowed to run.
- A learner may believe: “Temperature 0 is Freezing.” Respond: Freezing is below 0, so 0 is Cold; trace the edge values -1, 0, 14 and 15.
On the board or with the pen
- Write the two-IF program and trace 75 with the pen, showing both OUTPUT lines. Then write the nested version and trace again: only Distinction.
Checking understanding: The fix question: the swap and the > 70 options are the common wrong repairs; each is rebutted by tracing 75. The written temperature program shows whether pupils can apply nesting without help.
Depending on the answers
- If pupils choose the swap: trace 75 through the swapped program on the board and ask what would make the second test depend on the first.
- If pupils write < 14 for Cold: ask which output a temperature of 14 gets.
Support
- Give the first IF of the temperature program as a starting point and ask pupils to complete the ELSE.
Stretch
- Add a fourth outcome, Hot for 30 and over. Where does the new test go?
In the lesson window
- Think it through: A pupil scores 75. What does the program output, and what is wrong with that?
- Apply it: Which change makes the program output exactly one word for every mark: Distinction for 70 or more, Pass for 50 to 69, and nothing below 50?
- Think it through: Write pseudocode that inputs a whole-number temperature in degrees Celsius and outputs “Freezing” if it is below 0, “Cold” if it is from 0 to 14, and “Warm” otherwise. Then say how many IF statements you used and why.
7. Show what you know Consolidate 8 min
On the lesson window now
Purpose: Pupils explain why selection is needed and when to use CASE, then apply nested IF counting to a new context before the summary.
Ask
- Why does a program need selection, and when would you choose CASE rather than IF?
- How many IF statements does the library fee program need, and why?
Responses to expect
- Without selection a program does the same thing every time
- CASE for one variable and exact values, IF for ranges and combined tests
- Two, because three outcomes need two decisions
Misconceptions to challenge
- A learner may believe: “One variable means one IF.” Respond: One variable can lead to several outcomes; one IF splits into only two.
- A learner may believe: “There is one IF for every outcome.” Respond: The last outcome is whatever remains, so n outcomes need n - 1 decisions.
Checking understanding: Collect the explanations: a good answer gives a school example of each and names the type of test.
Depending on the answers
- If pupils choose three IF statements: ask which outcome needs no test of its own.
- If several are unsure about nesting order: start the next lesson by tracing the reversed grade calculator with 75 again.
In the lesson window
- Think it through: Explain to a friend why a program needs selection, and when you would choose CASE rather than IF. Give an example of each from a school setting.
- Apply it: A fictional library charges nothing if a book is returned on time (DaysLate = 0), 10 pence a day for up to 7 days late, and a flat 100 pence if it is more than 7 days late. How many IF statements does a correct nested solution need, and why?
Lesson recap Closing
On the lesson window now
On screen: the lesson’s objectives again; Next adds the closing question, which asks the class to explain each one in their own words without looking back. It says nothing about what anyone has learnt: use the answers to decide what to revisit.
Points to listen for
- Selection carries out lines only when a condition is true; IF ... ENDIF skips them when it is false.
- ELSE has no condition; exactly one of IF and ELSE runs; = in a condition asks, the arrow stores.
- Three outcomes need two nested decisions; the first true test decides, so test the most demanding group first.
- CASE compares one variable with exact values and OTHERWISE catches the rest; use IF for ranges.
- Trace the edge values to check the right symbol was chosen.
Consolidation
- Selection carries out lines only when a condition is true; IF ... ENDIF skips them when it is false.
- ELSE has no condition; exactly one of IF and ELSE runs; = in a condition asks, the arrow stores.
- Three outcomes need two nested decisions; the first true test decides, so test the most demanding group first.
- CASE compares one variable with exact values and OTHERWISE catches the rest; use IF for ranges.
- Trace the edge values to check the right symbol was chosen.