AP CSP Day 32: Simulations & Randomness
Share
Big Idea 3
Day 32 Practice
Focus: Simulations & Randomness
Practice Question
A program simulates rolling two dice. Which code segment correctly generates one roll?
Why This Answer?
RANDOM(1, 6) generates integers from 1 to 6 inclusive, matching standard dice values. Each die needs its own random call.
Why Not the Others?
B) Check exam reference - RANDOM(6) syntax may vary.
C) This generates 0-5, not 1-6 like real dice.
D) RANDOM(1, 7) would sometimes generate 7, invalid for dice.
Common Mistake
Watch Out!
Not checking the exam reference sheet for RANDOM syntax. The exam uses RANDOM(a, b) for inclusive ranges.
AP Exam Tip
Always verify procedure syntax on exam reference sheet before answering.