Need Help with this Question or something similar to this? We got you! Just fill out the order form (follow the link below), and your paper will be assigned to an expert to help you ASAP.
Question Description
Overview
In Module 5 Assignment 2, modify your pseudocode to make 1000 dicerolls, and instead of displaying the list, use Pygal to display theresults in a bar chart.
Instructions
M5 Assignment 2 uses both modules from M5-1 and asks you to modifythe second module to increase the number of rolls to 1000, to calculatehow frequently each number appears, and to display the results in a barchar, which is called a histogram in Pygal.
Some of the code is written for you, so review the two files formodule 1 in M5Lab2dice.py and module 2 in M5Lab2dice_hist.py file to seehow 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 M5Lab2dice_hist.py 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 “dice_barchart.svg” file
Add your name to the chart’s title
Test your chart by dragging the file dice_barchart.svg 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 M5Lab2ii.docx
Python code – Revise module 2 in M5Lab2dice_hist.py 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 results.count(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 pygal.Bar()
Declare a hist.title 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 M5Lab2dice_hist.py file into the same folder as dice.py
# Both program files must be in the same folder
Run your M5Lab2dice_hist.py file and see if it lists in the Pythonshell 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 “dice_barchart.svg”
Drag the dice_barchart.svg 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 logicbefore you write the program in Python and to turn in three things: 1)the pseudocode, 2) the dice_barchart.svg file, which displays the outputas 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 M5Lab2dice_hist.py
Upload your pseudocode in M5Lab2ii.docx
Upload your dice_barchart.svg files to M5 Assignment 2 Modular Design of Two Python Programs Assignment Submission Folder.
You do not need to post dice.py unless you made changes to the class file.
If you changed your Dice() class or its attributes, attach the changed files.
See the Schedule in the Syllabus Module for due dates. Review the Rubric attached to the Assignment Submission Folder for grading information.
