Short answer
In AP Computer Science Principles, selection is one of the three basic ways to build an algorithm. It lets an algorithm choose between paths based on a condition. The other two are sequencing, which runs steps in order, and iteration, which repeats steps.
Where selection fits in the course
AP Computer Science Principles teaches programming as a way to build algorithms, and it describes algorithms using sequencing, selection and iteration. Selection handles decisions. When a condition is true, one set of instructions runs. When it is false, another set may run, or none may.
Course materials and classroom examples often use a pseudocode style with IF and ELSE. Students may also see the same ideas in a real programming language. The underlying idea stays the same in both.
What students are expected to do
The practice work in a course like this usually focuses on applying selection, not only naming it. Students are typically asked to:
- write a selection that handles a stated condition
- trace code by hand, step by step, to find which branch runs
- predict the output for a given input
- choose a condition that matches a described situation
Selection in pseudocode
Here is a short example, with a score checked against a passing mark:
IF score >= 60
DISPLAY "Passed"
ELSE
DISPLAY "Not passed"
END IF
When the score is 75, the first branch runs. When the score is 50, the second branch runs. On any single pass through the code, only one of the two branches runs.
Tracing a selection by hand
Tracing means following the code line by line for one set of inputs. For selection, pick several inputs, including values on each side of the boundary. For the example above, check 59, 60 and 61. The value 60 is the exact edge of the condition, so it is the one most likely to be handled wrongly.
Writing down the value of each variable as you go helps. It also makes it easier to see where a mistake begins.
Common student mistakes
Some mistakes come up often:
- Writing a single IF when an IF-ELSE is needed, so one case is missed.
- Mixing up
>and>=, which changes the result at the boundary. - Writing nested IFs where one condition with AND would be clearer.
- Forgetting that the order of branches matters in a chain of conditions.
Studying selection effectively
Practice tracing before writing code. Take a short piece of code, predict its output for three inputs, then run it and compare. If the result differs, find the step where your reasoning went wrong.
Rewriting an IF-ELSE as nested IFs, then comparing the two versions, is also useful. It shows that the same logic can be written in more than one way, and that some ways are easier to read.
Confirm the current requirements
Course details can change, and this article does not give exact objective wording or exam structure. For the current requirements, read the official course description on AP Central, the College Board’s site. That document is the authoritative source for what the course covers.