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

. Dice rolling: In c++Write a program that simulates the rolling of two dice. The sum...
. Dice rolling: In c++Write a program that simulates the rolling of two dice. The sum of the two values should then be calculated. [Note: Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the least frequent sums.] The following table shows the 36 possible combinations of the two dice. Your program should...
Write a program in C++ called RollDice.cpp that simulates rolling a pair of dice until the...
Write a program in C++ called RollDice.cpp that simulates rolling a pair of dice until the total on the dice comes up to be a given number. Ask the user for the number that you are rolling for. To have your program roll two dice, use the rand() function this way: die1 = rand() % 6 + 1; die2 = rand() % 6 + 1; Your program then computes and prints the number of rolls it takes to get the...
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
Roll dice java program The program simulates a dice roll by generating a random integer between...
Roll dice java program The program simulates a dice roll by generating a random integer between 1 and 6
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...
(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:...
Python program that simulates the rolling a die until the number 5 is first obtained. Repeat...
Python program that simulates the rolling a die until the number 5 is first obtained. Repeat the experiment 10,000 times and print out the “Average Number of Rolls to Obtain a Six on a Die”, along with the average value. Include the average number of rolls your program calculates as a comment Please use comments to better explain what is happening
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...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT