AP Computer Science Principles Flashcards: Random Values
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.
What does it mean for each result of RANDOM(a, b) to be 'equally likely'?
It means that every integer within the range from a to b has the exact same probability of being generated and returned.
Card 1 of 10
All Flashcards (10)
What does it mean for each result of RANDOM(a, b) to be 'equally likely'?
It means that every integer within the range from a to b has the exact same probability of being generated and returned.
Write an expression to simulate a single roll of a standard six-sided die.
The expression RANDOM(1, 6) will generate a random integer from 1 to 6, inclusive.
What does the term 'inclusive' signify in the context of RANDOM(a, b)?
Inclusive signifies that both the lower bound 'a' and the upper bound 'b' are potential values that the function can return.
Write an expression to generate a random even integer between 2 and 10, inclusive.
The expression 2 * RANDOM(1, 5) will generate a random integer from the set {2, 4, 6, 8, 10}.
What is a primary consequence of using random number generation in a program?
A primary consequence is that each execution of the program may produce a different result, introducing variability.
What are all the possible results of evaluating the expression RANDOM(5, 8)?
The possible integer results are 5, 6, 7, and 8, as the range is inclusive.
Write an expression to generate a random integer that could represent a percentage, from 0 to 100 inclusive.
The expression RANDOM(0, 100) will generate a random integer within this range.
If a program uses the expression RANDOM(0, 1) to simulate a coin flip, what are the possible outcomes?
The two possible outcomes are 0 and 1, where each value could represent one side of the coin (e.g., heads or tails).
What is the function of RANDOM(a, b) as provided on the AP exam reference sheet?
RANDOM(a, b) generates and returns a random integer from a to b, inclusive, with each result being equally likely to occur.
Evaluate the expression RANDOM(-3, 1). What is the complete set of possible integer results?
The complete set of possible results is -3, -2, -1, 0, and 1.