Here Is My Dice Code I Am Not Really Sure About The Doublestats Function Here Th

Here is my dice code. I am not really sure about the doubleStats function here. The problem is to Study the doubleStats function and then run it giving 1000 as the argument. Does it produce a value that you would expect? Explain what doubleStats counts.

Also, Study and run the diceStats function. Try to figure out what it does and explain how it works. As a hint, run sum(diceStats(1000)) and explain its results).

def die_roll():

  roll = random.randint(1,6)

  return roll

def dice_roll():

  die1 = die_roll()

  die2 = die_roll()

  return die1 + die2

def doublesStats(trials):

  counter = 0

  for index in range(trials):

    roll1 = die_roll()

    roll2 = die_roll()

    if roll1 == roll2:

      counter = counter + 1

  return counter

def diceStats(trials):

  counterList = [0] * 13

  for counter in range(trials):

    result = dice_roll()

    counterList[result] = counterList[result] + 1

  return counterList

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *