(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 >>
(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 >>
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
>>](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3b25bdcc-1f5e-4716-88d3-d1e15ee2df25%2F6b55eedf-4b0d-42ae-b119-f0a91079ae15%2Fuqjodxl_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)