Question
PYTHON import random def quietCraps(): dice1=random.randint(1,6) dice2=random.randint(1,6) roll = dice1+dice2 if dice1 + dice2 == 7 or dice1 + dice2 == 11: return 1 elif
PYTHON
import random def quietCraps(): dice1=random.randint(1,6) dice2=random.randint(1,6) roll = dice1+dice2 if dice1 + dice2 == 7 or dice1 + dice2 == 11: return 1 elif dice1 + dice2 == 2 or dice1 + dice2 == 3 or dice1 + dice2 == 12: return 0 else: while True: dice1=random.randint(1,6) dice2=random.randint(1,6) if dice1 + dice2 == roll: return 1 elif dice1+dice2==7: return 0
1. implement a function testCraps that takes a positive integer n as a parameter, simulates n games of craps using the quietCraps function, and returns the fraction of games the player won. This function should not include the code and/or logic from the quietCraps function. Instead it should call that function. The following shows several sample runs of the function.
>>> random.seed(5)
>>> testCraps(10)
0.3
>>> random.seed(5)
>>> testCraps(100)
0.44
>>> random.seed(5)
>>> testCraps(1000)
0.497
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started