1. fInd the average win and lose rate of the crabs game 2. Find the Mean, Median, and mode of how long a player takes until he wins and loses a game.Basically find out how long each game lasts. With mean, median, and mode. This code is for python and its for the craps game. Below is the code I have so far.   import random import sys import pandas as pd def roll_dice(): die1 = random.randrange(1, 7) die2 = random.randrange(1, 7) return (die1, die2) def display_dice(dice): die1, die2 = dice print(f'Player rolled {die1} + {die2} = {sum(dice)}') # List that stores number of wins on every roll winList = [] # List that stores number of losses on every roll lossList = [] # List that stores label indexes of horizontal bar plot ylabel = [] # 1 # number of games of craps n = int(input("Enter number of games: ")) # Iterating 13 times # Because it is mentioned in the question that plot should have 13 # horizontal bars for wins, and 13 horizontal bars for losses. for roll in range(13): ylabel.append('Roll ' + str(roll + 1)) # variables that keep track of wins and losses on every roll # for the given number of games of craps wins = losses = 0 for i in range(n): die_values = roll_dice() display_dice(die_values) sum_of_dice = sum(die_values) if sum_of_dice in (7, 11): game_status = 'WON' wins += 1 elif sum_of_dice in (2, 3, 12): game_status = 'LOST' losses += 1 else: game_status = 'CONTINUE' my_point = sum_of_dice print('Point is', my_point) while game_status == 'CONTINUE': die_values = roll_dice() display_dice(die_values) sum_of_dice = sum(die_values) if sum_of_dice == my_point: game_status = 'WON' wins += 1 elif sum_of_dice == 7: game_status = 'LOST' losses += 1 if game_status == 'WON': print('Player wins') else: print('Player loses') winList.append(wins) lossList.append(losses)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. fInd the average win and lose rate of the crabs game

2. Find the Mean, Median, and mode of how long a player takes until he wins and loses a game.Basically find out how long each game lasts. With mean, median, and mode.

This code is for python and its for the craps game. Below is the code I have so far.

 

import random
import sys
import pandas as pd


def roll_dice():
die1 = random.randrange(1, 7)
die2 = random.randrange(1, 7)
return (die1, die2)


def display_dice(dice):
die1, die2 = dice
print(f'Player rolled {die1} + {die2} = {sum(dice)}')


# List that stores number of wins on every roll
winList = []

# List that stores number of losses on every roll
lossList = []

# List that stores label indexes of horizontal bar plot
ylabel = []

# 1
# number of games of craps
n = int(input("Enter number of games: "))

# Iterating 13 times
# Because it is mentioned in the question that plot should have 13
# horizontal bars for wins, and 13 horizontal bars for losses.
for roll in range(13):
ylabel.append('Roll ' + str(roll + 1))

# variables that keep track of wins and losses on every roll
# for the given number of games of craps
wins = losses = 0

for i in range(n):
die_values = roll_dice()
display_dice(die_values)
sum_of_dice = sum(die_values)
if sum_of_dice in (7, 11):
game_status = 'WON'
wins += 1
elif sum_of_dice in (2, 3, 12):
game_status = 'LOST'
losses += 1
else:
game_status = 'CONTINUE'
my_point = sum_of_dice
print('Point is', my_point)

while game_status == 'CONTINUE':
die_values = roll_dice()
display_dice(die_values)
sum_of_dice = sum(die_values)

if sum_of_dice == my_point:
game_status = 'WON'
wins += 1
elif sum_of_dice == 7:
game_status = 'LOST'
losses += 1
if game_status == 'WON':
print('Player wins')
else:
print('Player loses')
winList.append(wins)
lossList.append(losses)

Expert Solution
Step 1

In this question, it is asked to provide the python code for a problem statement.

The statement asks to find the average win and loss percentage of craps game 

It also asks to find the mean, median, and mode for the number of rolls of dice required for win/loss.

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education