Time for action – simulating a game show
Imagine a game show where every time the contestants answer a question correctly, they get to pull three balls from a jar and then put them back. Now there is a catch, there is one ball in there that is bad. Every time it is pulled out, the contestants lose six points. If however, they manage to get out three of the 25 normal balls, they get one point. So, what is going to happen if we have 100 questions in total? In order to get a solution for this, go through the following steps:
Initialize the outcome of the game with the
hypergeometric
function. The first parameter of this function is the number of ways to make a good selection, the second parameter is the number of ways to make a bad selection, and the third parameter is the number of items sampled.points = np.zeros(100) outcomes = np.random.hypergeometric(25, 1, 3, size=len(points))
Set the scores based on the outcomes from the previous step.
for i in range(len(points)): if outcomes[i] == 3...