Question: In Python def printDistribution(diceTally): ''' (20 points) Function that prints the diceTally distribution in a specific format (see lab instructions for more details). - This
- In Python
- def printDistribution(diceTally): ''' (20 points) Function that prints the diceTally distribution in a specific format (see lab instructions for more details). - This function does not return anything since it is simply printing to the console. - Note: Your algorithm must iterate and print each dice roll value in a loop. Do not simply have 11 print statements for each dice roll value. - Be VERY PRECISE in your format. Each character matters for full credit. ''' return
- The first line is simply Distribution of dice rolls followed by an empty line.
- The dice rolls are printed in a histogram format, one for each roll with additional information.
- Your solution should print this portion while iterating through the diceTally in a loop using the .format function. Do not simply write 10 print statements using .format.
- The dice roll values will have two spaces right-justified followed by a ':' character.
- Six spaces are reserved to print number of times a particular roll occurred, which is right-justified, followed by an empty space and open parenthesis, '(', characters.
- 5 spaces are reserved for the actual percentage value, with one space for the floating point value. This is followed by the '%)', and two blank spaces.
- The '*' character is printed the number of times a particular dice roll occurred.
- 30 hyphens - are printed after the diceRolls are printed
- The number of rolls are then printed
- .
An example printDistribution function will appear as follows: Distribution of dice rolls 7 ( 2.8%) * 16 ( 12: 250 rolls
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
