Question: The function random.randint from the random module can be used to produce an integer from a range of values. For example, random.randint(1,6) produces the values

The function random.randint from the random module can be used to produce an integer from a range of values. For example, random.randint(1,6) produces the values 1 to 6 with equal probability. Such a value can be used, for example, to simulate the roll of a die.

Using this technique, write a program that will allow the user to play either two rounds or four rounds of the popular dice game. This game program must ask the user to determine whether to play this game withtwo rounds or four rounds before rolling the dice.

The rules of craps are as follows:

A player rolls two dice.

  • If the sum of dice is either 2, 4 or 7 on the first throw, the player wins.
  • If the sum is 9 on the first throw, the player loses.
  • If the sum of the two dice does not belongs to the winning numbers or the losing number, then it becomes the players target number on the first throw.
  • To win, the player must continue rolling the dice until a roll matches to this target number.

Hint:

import random ------ used to load in the random number module for all the random functions.

1. An algorithm for this program

2. A copy of your program Python source code

!!pls pay attention to the steps, we need to determine win or lose on the first throw and then run the target number of first throw we dont have win or lose, the total rounds should be 2 or 4,. Thanks!!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!