Write a Python programs to do frequency counting of the sum of two dice. Your function should accept an integer nn parameter to run nn trials (i.e., multiple rollings of the two dice); You can use the Python function randrange(1, 7) to simulate the roll of one die; After running the nn trials, your function should return the sum of two dice that occurs most frequently. Please implement the following: sim_dice(n) Estimate the most probable sum of rolling two regular 6-faced dice repeatedly, using frequency counting. The function definition has already been started, below. It has one parameter, the number of rolls to perform on the two dice that you will frequency count. The return value will be the most common sum, and the frequency of that sum (e.g. the dice sum of 7 happens 142 times). main() The only purpose of this function is to call sim_dice(1000) and print the returned value of the most frequently occurring sum.   You are required to use this starter code as part of your solution: from random import randrange   def sim_dice(n):     # The sum of two dice range from minimum of 2 to a maximum of 12.     # Use this list to store the frequency of these sums     freqs = [-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]       _max = 0 # Store the sum of two dice the occurs most often.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a Python programs to do frequency counting of the sum of two dice.

  • Your function should accept an integer nn parameter to run nn trials (i.e., multiple rollings of the two dice);

  • You can use the Python function randrange(1, 7) to simulate the roll of one die;

  • After running the nn trials, your function should return the sum of two dice that occurs most frequently.

Please implement the following:

  • sim_dice(n)

    Estimate the most probable sum of rolling two regular 6-faced dice repeatedly, using frequency counting. The function definition has already been started, below. It has one parameter, the number of rolls to perform on the two dice that you will frequency count. The return value will be the most common sum, and the frequency of that sum (e.g. the dice sum of 7 happens 142 times).

  • main()

    The only purpose of this function is to call sim_dice(1000) and print the returned value of the most frequently occurring sum.

 

You are required to use this starter code as part of your solution:

from random import randrange
 
def sim_dice(n):
    # The sum of two dice range from minimum of 2 to a maximum of 12.
    # Use this list to store the frequency of these sums
    freqs = [-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 
    _max = 0 # Store the sum of two dice the occurs most often.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education