Unit 2 Cycle 1 Day 28: Comprehensive Unit 2 Review
Share
Comprehensive Unit 2 Review
Section Mixed — Review: All Unit 2
Key Concept
This comprehensive Unit 2 review integrates selection (if, if-else, else-if chains), iteration (while and for loops), boolean logic (compound expressions, De Morgan's Laws, short-circuit evaluation), and common algorithms (counting, accumulating, searching). On the AP exam, Unit 2 represents approximately 17-22% of questions. The most commonly tested topics are: De Morgan's Laws, loop tracing with off-by-one boundaries, nested loop iteration counts, and short-circuit evaluation with null checks.
Consider the following code segment.
What is printed as a result of executing the code segment?
Answer: (B) 120
This computes n factorial (5!). fact = 5 * 4 * 3 * 2 * 1 = 120. The loop counts down from 5 to 1, multiplying each value into fact.
Why Not the Others?
(A) 15 is 5+4+3+2+1 (sum, not product).
(C) 24 is 4! (4*3*2*1), which would result from starting at n=4 or using i >= 2.
(D) 5 is just the starting value of n, not the factorial.
Common Mistake
The factorial pattern multiplies all integers from n down to 1. Confusing multiplication with addition is common: product vs sum. 5! = 120, but 5+4+3+2+1 = 15.
AP Exam Tip
Recognize standard algorithms: factorial (multiply down), summation (add up), counting (increment per condition). Each uses an accumulator with a different operator.