Bartleby Related Questions Icon

Related questions

Question
(Perkovic, Problem 6.31b) Write a function testCraps that accepts a positive integer n as an
input, simulates n games and craps, and returns the fraction of games the player won.
⚫ the testCraps function should not make dice rolls directly, instead...
testCraps function should call the craps function repeatedly and keep track of the results
• if you your craps and testCraps function simulate the game correctly without any extra
rolls, you should be able to hit the results below exactly
1 >>> random.seed(0)
2
>>> testCraps (10000)
3
0.5
4
>>> random.seed(1)
5
>>> testCraps (10000)
6
7
8
0.4921
>>> [(i, random.seed(i), testCraps (100*i)) for i in range(1,10)]
[(1, None, 0.49), (2, None, 0.46), (3, None, 0.47333333333333333), (4, None,
0.5125), (5, None, 0.476), (6, None, 0.47333333333333333), (7, None,
0.4514285714285714), (8, None, 0.48), (9, None, 0.4855555555555556)]
9
>>
expand button
Transcribed Image Text:(Perkovic, Problem 6.31b) Write a function testCraps that accepts a positive integer n as an input, simulates n games and craps, and returns the fraction of games the player won. ⚫ the testCraps function should not make dice rolls directly, instead... testCraps function should call the craps function repeatedly and keep track of the results • if you your craps and testCraps function simulate the game correctly without any extra rolls, you should be able to hit the results below exactly 1 >>> random.seed(0) 2 >>> testCraps (10000) 3 0.5 4 >>> random.seed(1) 5 >>> testCraps (10000) 6 7 8 0.4921 >>> [(i, random.seed(i), testCraps (100*i)) for i in range(1,10)] [(1, None, 0.49), (2, None, 0.46), (3, None, 0.47333333333333333), (4, None, 0.5125), (5, None, 0.476), (6, None, 0.47333333333333333), (7, None, 0.4514285714285714), (8, None, 0.48), (9, None, 0.4855555555555556)] 9 >>
Expert Solution
Check Mark
Knowledge Booster
Background pattern image