AP CSP Topic 3.6 Guided Notes - Conditionals
Big Idea 3: Algorithms and Programming · Topic 3.6 · Guided Notes (Student)
Conditionals — Guided Notes
Fill these in during class or catch up here if you were absent. Print this page or work on paper — then check yourself with the CFUs on the Topic 3.6 page.
Print these notesAll CSP topics
Day 1: Teaching a Program to Decide
Today’s objectives
- Express a selection decision without using a programming language, showing how a condition being true or false chooses which steps run (LO AAP-2.G)
- Write an IF statement and determine its result — the block runs when the condition is true, and no action is taken when it is false (LO AAP-2.H)
Bell ringer
You are the gatekeeper at a concert, and you must train a substitute to take your place while you step away. The rule you follow: guests wearing a green wristband go to the VIP lounge; everyone else goes to general admission. Write the rule as numbered steps a stranger could follow with zero judgment calls.
Write 2–4 sentences: What did you have to name so the substitute knew what to check? Then decide what your steps do for a guest with a green band and for a guest with a blue band. Where in your steps does the path split?
01. Selection Without a Language
Key Vocabulary (LO AAP-2.G, AAP-2.H)
| Term | Definition (write it) |
|---|---|
| Selection | |
| Condition | |
| Conditional statement | |
| IF statement | |
| Flow of control |
What Selection Is
- Selection determines based on whether a condition is true or false.
- You can express a selection decision without any programming language by using .
- Selection is powerful because one algorithm can now depending on the input.
Two Ways to Express a Decision — No Code Needed
Plain-language rule
Flowchart / diagram
- Expressing selection without code still requires you to name the that decides which steps run.
- In a flowchart, a decision is drawn as a branch point with separate arrows for .
AP TIP: On free-response and multiple-choice, selection can appear as pseudocode OR as a plain description of a decision — recognize both as the same construct.
Stop and think
- In plain language (no code), write a selection rule for: a store posts a 'bring a jacket' note only when the forecast temperature is below 40. Name the condition clearly.
- Describe, in words, how you would draw the rule above as a flowchart: what goes in the decision shape, and where do the true and false arrows lead?
- Explain, in two sentences, how selection lets a single algorithm behave differently for two different inputs. Use the word condition.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.6 page.
02. The IF Statement
The IF Statement
- A plain IF is a one-way detour: after its block runs or is skipped, the program .
- When the condition is false in a plain IF, the block is (there is no hidden ELSE).
- A conditional statement changes the sequential flow of control based on the value of .
Run a Block When the Condition Is True
height is 50, so height ≥ 48 is true and the block runs.
AP Pseudocode (what the exam tests)
height ← 50
IF(height ≥ 48)
{
DISPLAY("Board the ride")
}
Python (the runnable version)
height = 50
if height >= 48:
print("Board the ride")
Output
Board the ride
Run and edit this yourself in the coding exercises for this topic.
Does the Block Run? Trace the IF
For the statement IF(height ≥ 48){ DISPLAY("Board the ride") }, evaluate the condition for each height, then decide whether the block runs and what is displayed. '(nothing)' means no action was taken.
Complete the empty cells.
| height | height ≥ 48 ? | Does the block run? | What is displayed |
|---|---|---|---|
| 52 | true | yes | |
| 48 | true | yes | Board the ride |
| 47 | no | (nothing) | |
| 40 | false | (nothing) |
Watch out — “Every IF Needs Something to Happen on False”
Myth: A plain IF must still do something when its condition is false — there is always a hidden default action.
Explain why this is wrong:
Stop and think
- Write an IF statement in exam pseudocode that displays "Free shipping" when a variable total is at least 50. Use the ≥ operator.
- Trace your statement for total = 50 and for total = 49. For each, state whether the block runs and what is displayed.
- A classmate writes IF(score < 60){ DISPLAY("Study more") } and asks what happens when score is 72. Answer precisely, and name the rule you used.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.6 page.
Today in one box
- Selection determines which parts of an algorithm run based on a condition being true or false
- You can express a decision with no code — plain language or a flowchart captures the same logic
- A conditional statement changes the sequential flow of control based on a Boolean expression
- IF(condition){ block } runs the block when the condition is true, and takes NO action when it is false
Before next class: Before tomorrow, predict it: score ← 55, then IF(score ≥ 60){ DISPLAY("Pass") } ELSE { DISPLAY("Retake") }. Write down what is displayed, and why.
Day 2: The Two-Way Fork
Today’s objectives
- Write an IF-ELSE statement in exam pseudocode so that exactly one of two blocks runs, depending on the condition (LO AAP-2.H)
- Determine the result of an IF or IF-ELSE by evaluating the condition first, then tracing which branch executes (LO AAP-2.H)
Bell ringer
Yesterday's teaser, now decide it. The program runs: score ← 55, then IF(score ≥ 60){ DISPLAY("Pass") } ELSE { DISPLAY("Retake") }. Three classmates predict the output will be Pass, Retake, and 'both Pass and Retake.'
Who is right, and exactly why? Write down the value of the condition score ≥ 60 first, then the single branch that runs. Name the mistake each wrong classmate made.
01. Adding ELSE — The Two-Way Fork
IF-ELSE: Exactly One Branch Runs
- In an IF-ELSE, the second block runs whenever the condition is .
- On any single pass of an IF-ELSE, the number of blocks that execute is .
- ELSE does not test its own condition; it runs for .
The Second Block Runs on False
height is 44, so height ≥ 48 is false and the ELSE block runs.
AP Pseudocode (what the exam tests)
height ← 44
IF(height ≥ 48)
{
DISPLAY("Board the ride")
}
ELSE
{
DISPLAY("Grow a bit more")
}
Python (the runnable version)
height = 44
if height >= 48:
print("Board the ride")
else:
print("Grow a bit more")
Output
Grow a bit more
Run and edit this yourself in the coding exercises for this topic.
IF Alone vs IF-ELSE
IF alone
IF-ELSE
- A plain IF may run block(s) on a pass; an IF-ELSE always runs exactly one.
- Reach for IF-ELSE instead of a lone IF whenever the false case .
AP TIP: If the question's false case must produce something, a lone IF is a bug — the missing ELSE is a classic exam trap.
Stop and think
- Write an IF-ELSE in exam pseudocode that displays "Adult ticket" when age ≥ 18 and "Youth ticket" otherwise. Use the ≥ operator and braces.
- Explain in one sentence why your statement can never display both ticket messages on the same run.
- Rewrite this plain IF so the false case is handled: IF(balance < 0){ DISPLAY("Overdrawn") }. Add an ELSE that displays "OK", and state which branch runs when balance is 25.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.6 page.
02. Determining the Result
Determining the Result: Which Branch?
- The first step in tracing any conditional is to .
- When the condition is true, the ELSE block is .
- Boundary inputs are tricky because .
Same Code, Two Inputs, Two Branches
The only change is temp; the condition's value decides which branch runs.
AP Pseudocode (what the exam tests)
temp ← 70
IF(temp ≥ 65)
{
DISPLAY("Warm")
}
ELSE
{
DISPLAY("Cool")
}
Python (the runnable version)
temp = 70
if temp >= 65:
print("Warm")
else:
print("Cool")
Output
Warm
Run and edit this yourself in the coding exercises for this topic.
Trace the Branch, Line by Line
For IF(height ≥ 48){ DISPLAY("Board the ride") } ELSE { DISPLAY("Grow a bit more") }, evaluate the condition for each height, name the branch taken, and give what is displayed.
Complete the empty cells.
| height | height ≥ 48 ? | Branch taken | What is displayed |
|---|---|---|---|
| 60 | true | IF (first block) | |
| 48 | IF (first block) | Board the ride | |
| 47 | false | Grow a bit more | |
| 30 | false | ELSE (second block) | Grow a bit more |
Watch out — “Both Branches of an IF-ELSE Run”
Myth: In IF(condition){ first block } ELSE { second block }, both blocks execute — or the ELSE runs as a follow-up after the IF.
Explain why this is wrong:
Stop and think
- Trace: n ← 12, IF(n MOD 2 = 0){ DISPLAY("Even") } ELSE { DISPLAY("Odd") }. Evaluate the condition first, then give the output.
- For IF(price ≤ 20){ DISPLAY("Budget") } ELSE { DISPLAY("Premium") }, give the output when price = 20 and when price = 21, and explain what the boundary shows.
- A classmate insists the statement in prompt 2 could display both "Budget" and "Premium" for one price. In one sentence, explain why that is impossible.
Show every step. Then check yourself with the matching CFUs on the Topic 3.6 page.
Common AP Traps
Three ways Topic 3.6 loses points on the exam — one minute now, real points in May.
A plain IF does nothing on false — in your own words:
IF-ELSE runs exactly one block — in your own words:
≥ and ≤ include the boundary — in your own words:
Conditionals, in One Slide
- Selection determines which parts of an algorithm run based on a condition being true or false, and can be expressed with no code — plain language or a flowchart.
- A conditional statement changes the sequential flow of control based on a Boolean expression.
- IF(condition){ block } runs the block on true and takes NO action on false.
- IF(condition){ first block } ELSE { second block } runs exactly one block — the first on true, the second otherwise; trace by evaluating the condition first.
Exit check — I can…
- ☐ express a selection decision without any programming language, naming the condition and both branches (LO AAP-2.G)
- ☐ write an IF statement and determine its result — block runs on true, no action on false (LO AAP-2.H)
- ☐ write an IF-ELSE so exactly one of two blocks runs depending on the condition (LO AAP-2.H)
- ☐ determine the result of any conditional by evaluating the condition first, then tracing the branch (LO AAP-2.H)
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]