How many total times the dice were thrown

Assignment Help Python Programming
Reference no: EM132360733

Question

Probability - Suppose we have a perfect six-sided standard die (the faces have the numbers 1 through 6, one number per side). If we roll the die, what number will come up? That question does not have a simple, correct answer. But a little thought suggests that if the die is tossed lots of times, then, on average, any one of the numbers from 1 to 6 should show up one sixth of the time.

This thinking leads to a definition. The theoretical probability of an event happening is the quotient of the number of outcomes favorable to the event divided by the total possible number of outcomes. When a single die is thrown once, there are six possible outcomes, and exactly one of them is favorable to the event of seeing a 4, say, and so the theoretical probability of seeing a 4 is 1/6. In fact, the theoretical probability of seeing any specific one of the numbers from 1 to 6 is 1/6.

We can also talk about the experimental probability of seeing a 4. This term applies when you actually take a die and toss it lots of times. You divide the number of times a 4 actually is seen by the total number of tosses to obtain the experimental probability of rolling a 4. If the number of tosses is large and the die is pretty good, then the experimental probability should be just about equal to the theoretical probability.

You can simulate all this with a computer. You can generate a "random" number between 1 and 6 and store the result. This will represent the result of a single "roll" of the die. Say you "rolled" a 4 in this way. You can immediately increment a counter, an integer variable. In this way you keep track of the number of times a 4 is "rolled." Repeat this procedure for a large number of "rolls." When this is finished, you can divide the number of times a 4 is "rolled", that's the value of the counter, by the total number of "rolls" to get a value for the experimental probability of "rolling" a 4.

If the simulation program is correct and you roll the die enough times, the experimental probability of rolling a 4 should be close to 1/6, the theoretical probability of rolling the 4. As a general rule, the more rolls, the closer the experimental probability should be to the theoretical probability.

Craps - A program written to simulate dice tossing could be at least mildly interesting. It would be even more interesting to have the dice being tossed in the context of simulating the old gambling game, Craps. For those of you who don't know the game, here are the rules:

The game is played with two standard six-sided dice. You roll two dice. The sum of the face on this first throw is called the point.

If the point is 7 or 11, you win the game immediately.If the point is 2 or 3 or 12, you lose the game immediately.If the point is anything else (4, 5, 6, 8, 9, or 10) you continue to toss the dice until you either match the point or roll a 7. If you match the point first, you win. If you roll the 7 first, you lose. Pick up a pair of dice and try it; you'll catch on to the rules pretty quickly. In this project you are going to program the computer to simulate the play of the game.

Processing:

Import random

Processing:

You will need to count the number of times the computer wins the game, how many total times the dice were thrown and how many times the individual face values were thrown. You should initialize these 8 variables to 0.

Prompt and receive from the user a random number generator seed. Echo-print. Convert this to anint.

Activate the random number generator with random.seed(s)where sis the seed value you just entered.

Prompt and receive from the user the number of games to be played. Don't forget to echo print.

Have the computer play the number of games of Craps specified. There should be no output to the screen while this is happening.

To get a random number for a die throw use variable = random.randint(1,6). This will return an integer value in the range 1 to 6. Remember each throw of the dice requires you get two random values, one for each of the die.

When complete, write a report containing the following:

A line containing the number of games played.

A line containing the total number of times a die was tossed. (This number will be even, right?)

A line containing the numbers 1 through 6 somewhat widely separated. These will serve as headings for the numbers in the following two lines.

A line containing the number of times each of the numbers 1 through 6 was tossed. These numbers will be under the headings printed on the line above.

A line containing the experimental probability that each of the numbers 1 through 6 was tossed. These numbers will also be under the headings and printed to 4 decimal places.

A line of output containing the number of times the game was won.

A line containing the experimental probability of winning a game of Craps. This should also be printed to 4 decimal places.

There will be some places where you have to repeat code in this project.Please do that rather than using functions.

Output should be easy to read. It must be possible to tell at a glance exactly what each of the numbers means. Use white space (blank lines) to separate unrelated lines of output, but in all cases all output must fit on one page. The outline above and these adminitions will force your output to look very, very like the sample output below.

Output Specifications

A sample keyboard run and output should look something like the following.

Reference no: EM132360733

Questions Cloud

Additional research on topic of diversification : Diversification- Conduct additional research on the topic of diversification.you opt to pursue related diversification, unrelated diversification
Design a simple computer program that allows them to store : You have been hired as a new computer programmer for Mountain Steelworks, Inc. As a part of your initial programming task, the owner has asked you.
Research recent news articles about ioof holdings : CGRM4000 - Corporate Governance, Sustainability and Ethics - research recent news articles and other information about IOOF Holdings
Explain how family systems theory can be used : Explain how family systems theory can be used to better understand the interactions of a modern family (traditional or nontraditional).
How many total times the dice were thrown : How many total times the dice were thrown and how many times the individual face values were thrown. You should initialize these 8 variables to 0.
How can restructuring help with strategy execution : How can restructuring help with strategy execution? What were the impacts of the restructuring on the organization and its customers?
Discuss about the physician quality reporting system : The Centers for Medicare and Medicaid (CMS) has been tracking and measuring health outcomes through several different, national methods.
Explain the importance of health promotion : Explain the importance of health promotion and the impact on the nation and the world. How much should the government play a role in our health?
How will you get a space-padded string with the original : How will you get a space-padded string with the original string left-justified to a total of width columns? The response paper should be in APA format.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd