There are errors in the following code snippet. Locate and fix all the errors with you! to get full credit for the question. Assume the goal of the program is to perform a simulation to estimate the probability of rolling three of a kind in a single roll of three six-sided dice.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 7E: (Simulation) Write a program to simulate the roll of two dice. If the total of the two dice is 7 or...
icon
Related questions
Question
Debugging:
There are errors in the following code snippet. Locate and fix all the errors with your own comments
to get full credit for the question. Assume the goal of the program is to perform a simulation to
estimate the probability of rolling three of a kind in a single roll of three six-sided dice.
File Edit Format Run Options Window Help
# Estimate the probability of rolling three of a kind
# in a singel roll of three six-sided dice.
def main ():
n input ("How many rolls would you like to simulate?")
hits = 0
for i in range (n):
if equalRolls (3):
hits += 1
print ("Estimated prob = ", float (hits) /n)
def equalRolls (count):
first = randrange (1,7)
for i in range (count) :
roll
if roll != first:
return False
return True
name
------
randrange (1,7)
1
if
main ()
Note: your output will not be exactly the same due to (pseudo)randomness
Test Case1:
How many rolls would you like to simulate? 100
Estimated prob = 0.01
_main____¹:
Test Case2:
How many rolls would you like to simulate? 10000
Estimated prob = 0.0265
Transcribed Image Text:Debugging: There are errors in the following code snippet. Locate and fix all the errors with your own comments to get full credit for the question. Assume the goal of the program is to perform a simulation to estimate the probability of rolling three of a kind in a single roll of three six-sided dice. File Edit Format Run Options Window Help # Estimate the probability of rolling three of a kind # in a singel roll of three six-sided dice. def main (): n input ("How many rolls would you like to simulate?") hits = 0 for i in range (n): if equalRolls (3): hits += 1 print ("Estimated prob = ", float (hits) /n) def equalRolls (count): first = randrange (1,7) for i in range (count) : roll if roll != first: return False return True name ------ randrange (1,7) 1 if main () Note: your output will not be exactly the same due to (pseudo)randomness Test Case1: How many rolls would you like to simulate? 100 Estimated prob = 0.01 _main____¹: Test Case2: How many rolls would you like to simulate? 10000 Estimated prob = 0.0265
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr