Unpredictability is a key characteristic of random numbers, meaning each generated number is independent and impossible to predict.
True
What does reproducibility in random number generators depend on?
The seed
To use random numbers in Python, you must import the random library.
What is the purpose of setting the seed in random number generation?
Ensure reproducibility
The `randint(a, b)` function in Python returns a random integer between `a` and `b` inclusive.
The `random.randint()` function generates a random integer within a specified range, excluding the upper bound.
False
What is the purpose of the `random.randint()` function in Python?
Generates random integers
The `random.randint()` function includes the upper bound, while `random.randrange()` excludes it.
True
`random.randint()` includes the upper bound, while `random.randrange()` excludes
Match the function with its description:
`random.randint(a, b)` ↔️ Returns a random integer between `a` and `b`, inclusive
`random.randrange(a, b)` ↔️ Returns a random integer from the range `a` to `b-1`, exclusive
What are three key characteristics of random number generation?
Unpredictability, uniformity, reproducibility
The Python `random.randint()` function returns a random integer, while `random.uniform()` returns a random float.
True
By setting the seed, the `random` library generates the same sequence of numbers each time the program is run
What is the difference between `random.randint()` and `random.randrange()` in terms of inclusivity of the upper bound?
`random.randint()` is inclusive
The `random.randrange()` function returns a random integer from the range `a` to `b-1`, which is exclusive
The `random.random()` function in Python generates a random floating-point number between 0.0 (inclusive) and 1.0 (exclusive), which is called its range
What is the purpose of the `random.seed(value)` function in Python?
Reproduce random sequences
Coin flip is an example of a game that uses random number generation to create unpredictable outcomes.
True
What is random number generation?
Producing unpredictable numbers
Uniformity in random numbers means they are evenly distributed across the possible range
Pseudo-random number generators (PRNGs) use a mathematical algorithm to generate sequences that appear random but are deterministic.
True
Match the random functions with their descriptions:
`randint(a, b)` ↔️ Returns a random integer between `a` and `b` inclusive.
`uniform(a, b)` ↔️ Returns a random floating-point number between `a` and `b`.
Random number generators in programming cannot produce the same sequence of numbers even if the seed is the same.
False
What type of number does the `uniform(a, b)` function return?
Floating-point
The `random.randrange()` function generates a random integer from the range `a` to `b-1`, which is exclusive.
The `random.randint(1, 100)` function generates a random integer between 1 and 100
What optional parameter can `random.randrange()` take to specify the increment between numbers?
step
The `random.random()` function generates a random float between 0 and 1, inclusive of 1.
False
Pseudo-random number generators use deterministic algorithms based on a seed
How can you ensure reproducibility of a random sequence in Python?
Set the seed
The `random.randint()` function generates a random integer between two specified values, inclusive.
True
What does the `random.randint(a, b)` function in Python do?
Generates random integers inclusive
`random.randint()` includes the upper bound, while `random.randrange()` excludes it.
True
What does `random.randrange(0, 100, 5)` generate a random number from?
A sequence with increment 5
`random.random()` generates floating-point numbers between 0.0 and 1.0.
True
Setting the seed to `42` in `random.seed(42)` ensures that the program always generates the same random number