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

Use python 3.5 version. Write a program that allows the user to play and study t

ID: 3847269 • Letter: U

Question

Use python 3.5 version.

Write a program that allows the user to play and study the game of craps

define player and die classes

player class must have __init__, __str__, play(this method plays the game and return True if there is a win, False otherwise), getnumberofrolls(this method returns the number of rolls)

die class must have __init__, __str__, roll( this method resets the die's value to a random number between 1 and 6), getvalue( this method returns the die's value)

With those two classes, make two more functions.

one that only plays one round of game, and other that plays n number of games(for example 1000 rounds of games).

the manygames functions most show the total number of wins and losses. the average number of rolls per win and the average number of rolls per loss, and finally the winning percentage.

Explanation / Answer

//I have different python program which is created for game of craps.
//Hope this will help you.

import random
import sys
  
def start():
print "Welcome to Python Craps!"
print "To start the game, press enter."
raw_input("")
comeout()
  
def comeout():
print "The come-out phase:"
print
raw_input("Hit ENTER to roll the dice...")
diceTotal = random.randint(1,6) + random.randint(1,6)
if diceTotal == 7 or diceTotal == 11:

print "You rolled a", diceTotal
print "You Win: Natural!"
print "Play again? Type 'y' for Yes, type 'n' for no."
play=raw_input()
if play=="y" or play=="Y":
comeout()
elif play=="n" or play=="N":
sys.exit()
else:
comeout()
'''wins=wins+1
results()'''
elif diceTotal == 2 or diceTotal == 3 or diceTotal == 12:
print "You rolled a", diceTotal
print "You Lose: Crap-Out!"
'''losses=losses+1
results()'''
print "Play again? Type 'y' for Yes, type 'n' for no."
play=raw_input()
if play=="y" or play=="Y":
comeout()
elif play=="n" or play=="N":
sys.exit()
else:
comeout()
else:
print "You Rolled a", diceTotal   
print "The Point Phase:"
print "Your point number is", diceTotal
print "You need to roll a", diceTotal, "before you roll a 7 to win! If you roll a 7, you lose!"
print "Rolling any other number is okay. You keep rolling until you win or lose!"
pointphase(diceTotal)
def pointphase(diceTotal):
raw_input("Hit ENTER to roll the dice...")
diceTotalPoint = random.randint(1,6) + random.randint(1,6)
if diceTotalPoint == diceTotal:
print "You Rolled a", diceTotalPoint
print "You Win: Hit!"
'''wins=wins+1
results()'''
print "Play again? Type 'y' for Yes, type 'n' for no."
play=raw_input()
if play=="y" or play=="Y":
comeout()
elif play=="n" or play=="N":
sys.exit()
else:
comeout()
elif diceTotalPoint == 7:
print "You Rolled a", diceTotalPoint
print "You lose: Seven-Out!"
'''losses=losses+1
results()'''
print "Play again? Type 'y' for Yes, type 'n' for no."
play=raw_input()
if play=="y" or play=="Y":
comeout()
elif play=="n" or play=="N":
sys.exit()
else:
comeout()
else:
print "You rolled a", diceTotalPoint
print "Roll Again!"
rollagain(diceTotal)

def rollagain(diceTotal):
raw_input("Hit ENTER to roll the dice...")
diceTotalPoint = random.randint(1,6) + random.randint(1,6)

if diceTotalPoint == diceTotal:
print "You Rolled a", diceTotalPoint
print "You Win: Hit!"
'''wins=wins+1
results()'''
print "Play again? Type 'y' for Yes, type 'n' for no."
play=raw_input()
if play=="y" or play=="Y":
comeout()
elif play=="n" or play=="N":
sys.exit()
else:
comeout()
elif diceTotalPoint == 7:
print "You Rolled a", diceTotalPoint
print "You lose: Seven-Out!"
'''losses=losses+1
results()'''
print "Play again? Type 'y' for Yes, type 'n' for no."
play=raw_input()
if play=="y" or play=="Y":
comeout()
elif play=="n" or play=="N":
sys.exit()
else:
comeout()
else:
print "You rolled a", diceTotalPoint
print "Roll Again!"
rollagain(diceTotal)
start()