Throw dice and compute a small probability.
Compute the probability of getting 6 eyes on all dice when rolling 7 dice. Since you need a large number of experiments in this case (see the first paragraph of Chapter 8.3), you can save quite some simulation time by using a vectorized implementation. Name of program file: roll_7dice.py.
Make a class for drawing balls from a hat. Consider the example about drawing colored balls from a hat in Chapter 8.3.3. It could be handy to have an object that acts as a hat:
# Make a hat with balls of 3 colors, each color appearing
# on 4 balls
hat = Hat(colors=(’red’, ’black’, ’blue’), number_of_each_color=4)
# Draw 3 balls at random
balls = hat.draw(number_of_balls=3)
Realize such code with a class Hat. You can borrow useful code from the balls_in_hat.py program and ideas from Chapter 8.2.5. Use the Hat class to solve the probability problem from Exercise 8.4. Name of program file: Hat.py.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here