Question

Hello. Below is a question that needs to be solved with Python. Q. Suppose that you...

Hello.
Below is a question that needs to be solved with Python.

Q. Suppose that you roll four 6-sided dice. Estimate the probabily that the die rolls are such that the four dice can be paired off so that one pair sums to 7 and the other sums to 9.

Here, I need 3 things.

a) Introdution - The Basic understanding of the problem.

b) Analysis - Explanation of the algorithm and display of the code that solves the problem.

b) Conclusion - Determine the solution of the problem and briefly discuss any potential generalizations.

please kindly show the solution clearly (Maybe with a screenshot of it too)

Thank you!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Basic Understanding Of The Problem

First of all, we have to check the pair of dice which will give sum 7.

There are 6 number of ways for getting the sum of pair of dice as 7. They are:

1 - 6

2 - 5

3 - 4

4 - 3

5 - 2

6 - 1

Next, we have to check the pair of dice which will give sum 9.

There are 4 number of ways for getting the sum of pair of dice as 9. They are:

3 - 6

4 - 5

5 - 4

6 - 3

It is given that the dice is 6-sided. So, for 1 dice, total probability of getting any values is 6. So, for a pair of dice, total probability of getting any values is 6*6=36.

Therefore, the probability of pair of dice to give sum as 7 = 6/36= 1/6

The probability of pair of dice to give sum as 9 = 4/36= 1/9

Since the first pair of dice should give sum as 7 AND the second pair of dice should give sum as 9, we have to add both probabilities.

That is, 1/6 + 1/9 = 5/18

Analysis

Algorithm

1. Start

2.For i =1 to 6

2.1.For j=1 to 6

2.2 If i+j =7 then

2.2.1. flag1 = flag1 +1

3.For i =1 to 6

3.1.For j=1 to 6

3.2 If i+j =9 then

3.2.1. flag2 = flag2 + 1

4. Print the Probability by adding flag1+flag2

5.Stop

Program

flag1=0 #inistialised variables with 0
flag2=0

for i in range(1,7):
for j in range(1,7):
if i+j == 7:
flag1=flag1+1 #checking if the sum of first pairs of dice is 7 and incrementing flag1
  
  
for i in range(1,7):
for j in range(1,7):
if i+j == 9:
flag2=flag2+1 #checking if the sum of first pairs of dice is 9 and incrementing flag2
  

#Output

print ("Probability of pair of dice with sum 7 = ",flag1,"/36")
print("Probability of pair of dice with sum 9 =",flag2,"/36")

print("Total Probability =", flag1+flag2,"/36")

Output

Probability of pair of dice with sum 7 = 6 /36

Probability of pair of dice with sum 9 = 4 /36

Total Probability = 10 /36

Generalised Program

I have also created an altered program where you can do the same with different numbers.

Example

Note: Probability should be always be in its least divisible form.That is, for above answer 9/36, it should be 1/4.

Add a comment
Know the answer?
Add Answer to:
Hello. Below is a question that needs to be solved with Python. Q. Suppose that you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help with Intro to Comp Sci 2 (Python) problem: This is what is provided: (Copy/Paste...

    Need help with Intro to Comp Sci 2 (Python) problem: This is what is provided: (Copy/Paste version): from tkinter import Tk, Label, Entry, Button from random import * class Craps(Tk): #set up the main window def __init__(self, parent=None): Tk.__init__(self, parent) self.title('Play Craps') self.new_game() self.make_widgets() #when a new game is started, the firstRoll will start at 0 def new_game(self): self.firstRoll = 0    #create and place the widgets in the window def make_widgets(self): Label(self, text="Die 1").grid(row=0, column=0, columnspan=1) Label(self, text="Die 2").grid(row=0,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT