AP CSP Day 25: Accumulator Pattern

Big Idea 3: Algorithms & Programming
Cycle 1 • Day 25 Practice • Medium Difficulty
Focus: Conditionals

Practice Question

What is displayed after the following code runs?

temp ← 72
IF temp > 80
{
   DISPLAY("hot")
}
IF temp > 60
{
   DISPLAY("warm")
}
IF temp > 40
{
   DISPLAY("cool")
}
Why This Answer?

These are three separate IF statements (not IF/ELSE), so each one is evaluated independently. With temp = 72: 72 > 80 is false (skip), 72 > 60 is true (display "warm"), 72 > 40 is true (display "cool"). Both "warm" and "cool" are displayed.

Why Not the Others?

A) 72 is not greater than 80, so "hot" is not displayed. B) The third IF statement also evaluates to true, so "cool" is displayed too. D) The first condition is false, so "hot" is not included.

Common Mistake
Watch Out!

Students treat separate IF statements as an IF/ELSE chain, thinking that once one condition is true, the rest are skipped. Separate IF statements each evaluate independently.

AP Exam Tip

Critical distinction: separate IF statements all evaluate independently. IF/ELSE chains stop at the first true condition. Look for ELSE to determine which pattern is being used.

Keep Practicing!

Consistent daily practice is the key to AP CSP success.

AP CSP Resources Get 1-on-1 Help
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.