Question: python please. this code was incorrect In this exercise you will simulate 100 rolls of n dice. Write a function named create_dice_dictionary(n) which takes an

python please. this code was incorrect In this exercise you will simulatepython please. this code was incorrect

In this exercise you will simulate 100 rolls of n dice. Write a function named create_dice_dictionary(n) which takes an integer n as a parameter and returns a dictionary. The function should simulate rolling n six-sided dice for 100 times. As the function runs, it should count the number of times that each total of the dice occurs. Create a dictionary of keys from n to n * 6 inclusive. Each key has a corresponding value which is the number of times each total occurs. You can assume that the integer parameter is positive (i.e. greater than 0). Note: you should use the following code in order to generate the same set of random numbers: import random random.seed (30) For example: Test Result print(create_dice_dictionary(2)) {2: 2, 3: 6, 4:6, 5: 11, 6: 16, 7: 15, 8: 16, 9: 15, 10: 7, 11: 5, 12: 1} Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Reset answer 1 import random 2 random.seed(30) 3 def create_dice_dictionary(n): rolls = {} for i in range(n,n*6+1): rolls[i] = 0 for i in range(100): dice_sum = sum(random.choices (range(n, n*6 + 1), k = n)) 10 rolls[dice_sum] += k 11 return rotis non

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!