Questions: Random Numbers and Simulation

4 questions to test your understanding

Score: 0 / 4
Question 1 Multiple Choice

In Java, Math.random() returns a double d with 0.0 <= d < 1.0. Which expression produces a random integer from 1 to 6, each value equally likely?

A(int) (Math.random() * 6)
B(int) (Math.random() * 6) + 1
C(int) (Math.random() * 7)
D(int) Math.random() * 6 + 1
Question 2 Multiple Choice

A program calls random.seed(42) and then prints five calls to random.randint(1, 100). It is run twice on the same Python version. What happens?

AThe two runs print different numbers, because the values are random
BThe two runs print the same five numbers
CThe second run raises an error, because a seed can be used only once
DBoth runs print 42 five times
Question 3 True / False

Running a simulation with more trials always produces the exact true probability.

TTrue
FFalse
Question 4 Short Answer

A city simulates traffic at a new intersection instead of building it and watching. Give one advantage of the simulation and one limitation.

Think about your answer, then reveal below.