Selection

In AP Computer Science Principles, selection is the algorithmic construct that lets a program choose between different paths of execution based on whether a condition is true or false, typically written with IF and ELSE statements. It's one of the three building blocks of every algorithm, alongside sequencing and iteration.

Verified for the 2027 AP Computer Science Principles examLast updated June 2026

What is Selection?

Selection is how a program makes decisions. The program evaluates a condition (a Boolean expression that comes out true or false) and then runs one block of code or another based on the result. In AP CSP pseudocode, you'll see this as IF and IF...ELSE statements. Think of it as a fork in the road. Without selection, code just marches straight through every line in order. With selection, the program can skip code, branch, and respond differently to different inputs.

The CED treats selection as one of the three fundamental algorithmic constructs. Per EK AAP-2.A.4, every algorithm can be constructed using combinations of sequencing, selection, and iteration. That sentence is exam gold. Sequencing runs statements in order, selection chooses between paths, and iteration repeats steps. Selection is the only one of the three that lets your program react to a condition, which is why you can't fake it with the other two.

Why Selection matters in AP Computer Science Principles

Selection lives in Unit 3: Algorithms and Programming, anchored to Topic 3.3 and the surrounding algorithm topics. It directly supports learning objectives AP Comp Sci P 3.3.A and 3.3.B, which ask you to express algorithms (in pseudocode, natural language, or diagrams) and represent step-by-step processes in code. You can't write a meaningful algorithm without knowing when to use selection versus plain sequencing.

Selection also connects to expression evaluation (EK AAP-2.B.3 and 2.B.4). Every selection statement is built on a condition, and a condition is just an expression that evaluates to a single Boolean value. So the skills from Topic 3.3, like evaluating expressions with operators in the right order, feed directly into writing correct IF statements. If you misevaluate the condition, you take the wrong branch.

How Selection connects across the course

Condition (Unit 3)

Selection doesn't work without a condition. The condition is the Boolean expression inside the IF statement, and the selection construct is the decision the program makes based on it. The condition asks the question; selection acts on the answer.

If Statement and Else Statement (Unit 3)

IF and ELSE are how you actually write selection in AP CSP pseudocode. An IF alone runs code only when the condition is true. Adding ELSE gives the program a guaranteed second path when it's false.

Modulus Operator (Unit 3)

MOD shows up constantly inside selection conditions. The classic move is IF (num MOD 2 = 0) to check if a number is even. The exam loves pairing arithmetic operators from Topic 3.3 with selection logic, like summing only the even numbers from 2 to n.

Arithmetic Operators (Unit 3)

Conditions often compare the results of arithmetic expressions, so order of operations matters before the branch even happens. The expression gets evaluated to a single value first, then selection decides what to do with it.

Is Selection on the AP Computer Science Principles exam?

Multiple-choice questions test whether you can identify which constructs an algorithm needs. A classic stem gives you a task, like summing all even numbers from 2 to n, and asks which combination of sequencing, selection, and iteration is necessary and sufficient. (That one needs all three: sequence the steps, iterate through the numbers, and select only the evens.) Another favorite is a true/false-style conceptual question, like whether selection can be rewritten using only sequencing and iteration. It can't. Selection is fundamental, which is exactly why EK AAP-2.A.4 lists all three constructs.

Selection also matters for the Create Performance Task and the written response questions tied to it, where you explain how your program's algorithm works. Recent exam scoring criteria, including the 2023 rubrics and the 2025 written response questions, expect you to identify and explain selection in your own code. Know how to point at an IF/ELSE block and say what condition it checks and what each branch does.

Selection vs Iteration

Both change the flow of a program, but they do different jobs. Selection chooses between paths once (the program checks a condition and goes left or right). Iteration repeats a block of code multiple times. The mix-up happens because loops contain conditions too. The difference is what the condition controls. In selection, the condition picks a branch. In iteration, the condition decides whether to keep looping. A REPEAT UNTIL loop is iteration even though it uses a condition; an IF statement inside that loop is selection.

Key things to remember about Selection

  • Selection is the algorithmic construct that lets a program choose between different paths of execution based on whether a condition is true or false.

  • Every algorithm can be built from combinations of sequencing, selection, and iteration (EK AAP-2.A.4), and selection cannot be replaced by the other two.

  • In AP CSP pseudocode, selection is written with IF statements (one possible path) and IF...ELSE statements (two guaranteed paths).

  • Every selection statement depends on a condition, which is an expression that evaluates to a single Boolean value, so expression evaluation skills from Topic 3.3 feed directly into selection.

  • Many exam problems combine selection with arithmetic, like using MOD inside a condition to check whether a number is even before adding it to a sum.

  • On the exam, be ready to identify which of the three constructs an algorithm requires and to explain how selection works in a given block of code.

Frequently asked questions about Selection

What is selection in AP Computer Science Principles?

Selection is the process of a program choosing between different paths of execution based on a condition. In AP CSP pseudocode it's written with IF and IF...ELSE statements, and it's one of the three fundamental algorithmic constructs alongside sequencing and iteration.

Can selection be replaced by just sequencing and iteration?

No. This is a tested misconception. EK AAP-2.A.4 says every algorithm is built from sequencing, selection, AND iteration because each construct does something the others can't. Only selection lets a program branch based on a condition.

What's the difference between selection and iteration?

Selection makes a one-time choice between paths (IF/ELSE), while iteration repeats a block of code (loops like REPEAT UNTIL). Both use conditions, but in selection the condition picks a branch, and in iteration the condition controls whether the loop keeps running.

Is an IF statement the same thing as selection?

Pretty much, yes. Selection is the concept (a program choosing a path based on a condition), and the IF statement is how you implement that concept in code. On the exam, spotting an IF or IF...ELSE block means you've found selection.

Do I need selection for the Create Performance Task?

Yes. The Create task and its written response questions expect your program to include selection, usually an IF/ELSE inside your main algorithm, and you should be able to explain what condition it checks and what each branch does.