Using pyhton can anyone help me with this coding? Request Write a program that a
ID: 3847296 • Letter: U
Question
Using pyhton can anyone help me with this coding?
Request Write a program that allows the user to play and study the game of craps Analysis: define Player and Die classes User interface: prompt for number of games to play play OneGame playManyGames (2, 2) 4 Enter the number of games: 100 (2 1) 3 The total number of wins is 49 (4 6) 10 The total number of losses is 51 (6 5) 11 The average number of rolls per win is 3.37 (4, 1) 5 The average number of rolls per loss is 4.20 (5 6) 11 The winning percentage is 0.490 (3 5) 8 (3 1) 4 You win!Explanation / Answer
from random import randint from sys import exit import os os.system('clear') print "Welcome to the dice rolling simulator!" raw_input("Press enter to begin.") total = 0 completed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] def roll(): os.system('clear') die1 = randint(1, 6) die2 = randint(1, 6) global total total = die1 + die2 storetotal() print "Die 1: %d Die 2: %d Total: %d." % (die1, die2, total) print " Roll again?" roll_again = raw_input("Press enter to roll again, type 'stats' to view scores, or 'quit' to exit. > ") if roll_again == "": roll() elif roll_again == "stats": stats() elif roll_again == "quit": exit(0) else: print "I don't know what that means so you get to roll again." raw_input("> ") roll() def stats(): global total print "2s: %d 3s: %d 4s: %d 5s: %d 6s: %d 7s: %d 8s: %d" % (completed[0], completed[1], completed[2], completed[3], completed[4], completed[5], completed[6]) print "9s: %d 10s: %d 11s: %d 12s: %d""" % (completed[7], completed[8], completed[9], completed[10]) raw_input("") roll() def storetotal(): if total == 2: completed[0] += 1 elif total == 3: completed[1] += 1 elif total == 4: completed[2] += 1 elif total == 5: completed[3] += 1 elif total == 6: completed[4] += 1 elif total == 7: completed[5] += 1 elif total == 8: completed[6] += 1 elif total == 9: completed[7] += 1 elif total == 10: completed[8] += 1 elif total == 11: completed[9] += 1 else: completed[10] += 1 roll()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.