Overview
In Module 5 Assignment 2, modify your pseudocode to make 1000 dice rolls, and instead of displaying the list, use Pygal to display the results in a bar chart.
Instructions
M5 Assignment 2 uses both modules from M5-1 and asks you to modify the second module to increase the number of rolls to 1000, to calculate how frequently each number appears, and to display the results in a bar char, which is called a histogram in Pygal.
Some of the code is written for you, so review the two files for module 1 in [login to view URL] and module 2 in [login to view URL] file to see how the lab works. Some of the code is missing in M5Lab2dice_hist.py.
Read both program files to see what is missing. You will revise your pseudocode and revise the [login to view URL] file.
Pseudocode - Revise module 2 in your pseudocode to add these steps:
Roll the dice 1000 times
Do not print the results
Instead, print the frequencies from a list called frequencies[]
Frequencies are the number of times each number appears
Add the titles to your bar chart
# They are string values that appear at the top
# List the titles for the x axis and the y axis of your chart
# See the example in the code to support your pseudocode
Render the chart to appear in a “[login to view URL]” file
Add your name to the chart’s title
Test your chart by dragging the file [login to view URL] into any Web browser window
If you see your bar chart with 6 columns, examine it
Hover your cursor over each column to see the values for 1000 dice rolls
Save your pseudocode as [login to view URL]
Python code - Revise module 2 in [login to view URL] to add these steps:
import Pygal # Pygal draws the bar chart or histogram for you
import the Dice class # from dice import Dice
declare the variable dice and assign the value to the class name Dice()
# variable_name = Class()
Declare an empty list called results
Declare an empty frequencies list for the tracking how often each die value appears
Declare a variable frequency and assign it to [login to view URL](value)
# Tracks the number of times each value from 1-6 is rolled
print the frequencies # the format is print(listname)
Bar chart: declare a variable hist and assign it the value [login to view URL]()
Declare a [login to view URL] variable and set the value to the following
Your Name - Results of 1000 6-Sided Dice Rolls
Replace “Your Name” with your name
Declare a hist.x_title and set the value to Result using a string
Declare a hist.y_title and set the string value to "How Often Did We Roll a 1, 2, 3, 4, 5, or 6?"
# Tip: do not copy the string values surrounded by quotes from A MS Word file.
# They use the wrong quotation symbols. Retype the quotation marks in Python.
Save your [login to view URL] file into the same folder as [login to view URL]
# Both program files must be in the same folder
Run your [login to view URL] file and see if it lists in the Python shell the number of times each number appeared on the dice rolls.
Open the folder with your labs in it
The results and frequencies from 1000 rolls appear in a hist.render_to_file called “[login to view URL]”
Drag the [login to view URL] file from your folder to a Web browser window to see your bar chart
Hover over the columns to see the frequencies appear
Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) the [login to view URL] file, which displays the output as a bar chart, and 3) your Python program.
How to Complete Your M5 Assignment Modular Design of Two Python Programs
In the M5 Assignment 2 Modular Design of Two Python Programs Assignment Submission Folder:
Upload [login to view URL]
Upload your pseudocode in [login to view URL]
Upload your [login to view URL] files to M5 Assignment 2 Modular Design of Two Python Programs Assignment Submission Folder.
You do not need to post [login to view URL] unless you made changes to the class file.
If you changed your Dice() class or its attributes, attach the changed files.
Greetings
i am software developer with 6+ years experience, i will help you to build your Python program.
I specialize in Python, C#, Java and Php.
It's my pleasure to work on your Project.
Please Send me a message so that we can discuss more about this project.
Waiting to hear from you