Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Craps is a dice-based game played in many casinos. Like blackjack, a player plas

ID: 3547775 • Letter: C

Question

Craps is a dice-based game played in many casinos. Like blackjack, a player plas against the house. The game starts with the player throwing a pair of standard, six-sided dice. If the player rolls a total of 7 or 11, the player wins. If the player rolls a total of 2, 3 or 12 the player loses. For all other roll values, the player will repeatedly roll the pair of dice until either she rolls the initial value again(in which case she wins) or 7 in which case she loses)


(a) implement function craps() that takes no argument, simulates one game of craps, and returns 1 if the player won and 0 if the player lost.


>>>craps()

0

>>>craps()

1

>>>craps()

1


(b) implement function testCraps() that takes a positive integer n as input, simulates n games of craps, and returns the fraction of games the player won.


>>>testCraps(10000)

0.4844

>>>testCraps(10000)

0.492

Explanation / Answer

Now a second problem, here's the fixed code with comments: