Sera H.

asked • 03/16/21

python dice game

Craps is a dice game played with two 6 sided dice. Play the demo to see how it works.


The rules of the game of Craps are as follows:

You roll two dice. On the first roll of a game, if the sum of the dice is:
  1. 2, 3 or 12 you lose
  2. 7 or 11 you win
If you roll any other sum this is called your goal. Store this value and then keep rolling. On subsequent rolls, if the sum is:
  1. your goal again you win
  2. 7 you lose
Keep rolling until you get your goal or a 7.


You will write a program that will play a game of craps. The basic gameplay can only use four variables. You may use two to four variables for the betting aspect of the game.


At the beginning of the game, the user will start at $100. You will allow the user to bet any whole number that is less than or equal to the amount of money they currently have. You must check the input. If the input is negative the game ends. If the input is not an integer or bigger than the allowed amount, they must try again.


If the user wins, add the amount they bet to their original total. If the user loses, subtract the bet from their original total. Once the user has less than or equal to $0 remaining, they can no longer play (game ends).


After each roll print the values of the two dice. Print a message at the end of the game saying if they won or lost. Here are 7 different sample runs of the game. Be sure to test your code and check carefully!



1 Expert Answer

By:

Patrick B. answered • 03/16/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.