Answered! please this function for python 3.5 and please I dont want any answers from the user Anonymous because all his are incoreect…

please this function for python 3.5 and please I dont want any answers from the user Anonymous because all his are incoreect

Craps is a dice-based game played in many casinos. Like blackjack, a player plays 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/he rolls the initial value again (in which case she/he wins) or 7 (in which case she/he loses).

Don't use plagiarized sources. Get Your Custom Essay on
Answered! please this function for python 3.5 and please I dont want any answers from the user Anonymous because all his are incoreect…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Write a function craps that takes no parameters, simulates one game of craps, and returns 1 if the player won and 0 if the player lost. It should also print a history of the rolls so that the player can verify that the function is doing the right thing. The following shows several sample runs of the function:

>>> random.seed(1)

>>> craps()

2 5

1

>>> random.seed(2)

>>> craps()

1 1

0

>>> random.seed(9)

>>> craps()

4 5

3 3

2 2

6 1

0

>>> random.seed(7)

>>> craps()

3 2

4 6

1 1

5 1

3 5

1 5

2 1

1 4

1

>>>

Expert Answer

 Answered! please this function for python 3.5 and please I dont want any answers from the user Anonymous because all his are incoreect... 1

from random import randint # for generating random values

# defining function
def craps():

# generating two random numbers between 1 and 6
one = randint(1,6)
two = randint(1,6)

# adding both and printing
dice = one + two
print one, two

# Direct win case
if dice == 7 or dice == 11:
return 1

# Direct lose case
elif dice == 2 or dice == 3 or dice == 12:
return 0

# Case3, lose if 7 comes
else:
temp = 0
while temp!=7:
# generating 2 random numbers and summing up
one = randint(1,6)
two = randint(1,6)
temp = one + two
print one, two

# verifying if it is as first generate number
# if true, returns 1 else runs until it is 7
if temp == dice:
return 1

# comes here from case 3 only and if the value is 7
return 0
print craps()

Answered! please this function for python 3.5 and please I dont want any answers from the user Anonymous because all his are incoreect... 2

Still stressed from student homework?
Get quality assistance from academic writers!