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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!