Question

In: Computer Science

1. Write a program which simulates rolling dice. It should: Display the random number rolled Ask...

1. Write a program which simulates rolling dice. It should: Display the random number rolled Ask the user if they want to roll again. If they don't want to roll again, the program should end. If they do want to roll again, the new number should display. At a minimum, the die should have 6 sides, but if you want to use a d12 or d20, that is fine too.

USE PYTHON

Solutions

Expert Solution

import random

# Using randrange() to generate numbers from 1-6

ch="y"

while(ch=="y"):

n=random.randrange(6)+1

print(n)

ch=input("do you want roll again (y/n)?")

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

PYTHON BEGINNER Problem Write a program which, given a number, simulates rolling a pair of six-sided...
PYTHON BEGINNER Problem Write a program which, given a number, simulates rolling a pair of six-sided dice that number of times. The program should keep track of how many times each possible sum comes up using a list. The list's first element should contain how many times a total of 2 was rolled, the second should contain how many times a total of 3 was rolled, and so on all the way through to 12. When all rolls are complete,...
Two dice are rolled. Determine the probability of the following. Rolling an even number or a...
Two dice are rolled. Determine the probability of the following. Rolling an even number or a number greater than 10
Write a Java program to simulate the rolling of two dice. The application should use an...
Write a Java program to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12. Your application should roll the dice 36,000,000 times. Store the results of each roll...
Write a python program that simulates a simple dice gambling game. The game is played as...
Write a python program that simulates a simple dice gambling game. The game is played as follows: Roll a six sided die. If you roll a 1, 2 or a 3, the game is over. If you roll a 4, 5, or 6, you win that many dollars ($4, $5, or $6), and then roll again. With each additional roll, you have the chance to win more money, or you might roll a game-ending 1, 2, or 3, at which...
(1) Consider the random experiment where three 6-sided dice are rolled and the number that comes...
(1) Consider the random experiment where three 6-sided dice are rolled and the number that comes up (1, 2, 3, 4, 5 or 6) on each die is observed. (a) What is the size of the sample space S of this random experiment? (b) Find the probability of event E1: “All three numbers rolled are the same.” (c) Find the probability of event E2: “The sum of the three numbers rolled is 5.” (d) Find the probability of event E3:...
Q1. Two fair dice are rolled. What is the probability of… a)         Rolling a sum of...
Q1. Two fair dice are rolled. What is the probability of… a)         Rolling a sum of 4 or doubles? b) Rolling a sum of 4 and doubles c)         Rolling a sum of 2, 4 times in a row? Q2. True or False. A discrete sample space is one in which outcomes are counted
1 (a) A pair of dice is rolled, and the number that appears uppermost on each...
1 (a) A pair of dice is rolled, and the number that appears uppermost on each die is observed. Refer to this experiment and find the probability of the given event. (Enter your answer as a fraction.) The sum of the numbers is either 7 or 11. (b) An experiment consists of selecting a card at random from a 52-card deck. Refer to this experiment and find the probability of the event. (Enter your answer as a fraction.) A face...
Two dice are rolled. Let the random variable X denote the number that falls uppermost on...
Two dice are rolled. Let the random variable X denote the number that falls uppermost on the first die and let Y denote the number that falls uppermost on the second die. (a) Find the probability distributions of X and Y. x 1 2 3 4 5 6 P(X = x) y 1 2 3 4 5 6 P(Y = y) (b) Find the probability distribution of X + Y. x + y 2 3 4 5 6 7 P(X...
1. Let’s use Excel to simulate rolling two dice and finding the rolled sum. • Open...
1. Let’s use Excel to simulate rolling two dice and finding the rolled sum. • Open a new Excel document. • Click on cell A1, then click on the function icon fx and select Math&Trig, then select RANDBETWEEN. • In the dialog box, enter 1 for bottom and enter 6 for top. • After getting the random number in the first cell, click and hold down the mouse button to drag the lower right corner of this first cell, and...
Two fair dice are rolled. What is the probability of… a)Rolling a total of 8? b)...
Two fair dice are rolled. What is the probability of… a)Rolling a total of 8? b) Rolling a total greater than 5? c)Rolling doubles? d)Rolling a sum of 6 or a sum of 8? e)Rolling a sum of 4 or doubles? f)Rolling a sum of 4 and doubles? g)Rolling a sum of 2, 4 times in a row?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT