Question: For this assignment, I recommend that you start with existing code (e.g., the sugar content code) and modify it. For this assignment you will write

For this assignment, I recommend that you start For this assignment, I recommend that you start with existing code (e.g., the sugar content code) and modify it. For this assignment you will write a Python program that . uses a CSV file as input, . plots the contents, . saves the plot as a file, . and displays it. Here is the file you will use as input: wordCount.csy. Download the word count file to the same folder where you be will saving your Python program Step-by-step: . Import the files for matplotlib and numpy Open the CSV file . Use the file contents to create two lists: chars counts - b . An easy way to do this is to loop through the file object line by line, and o for each line, . strip out the newline character, . split the string into a list, . and append the first element of the line to chars . and the second to counts, . Close the file . Initialize a plot figure . Set the figure width to 15 . Set the figure height to 5 . Create two arrays, xpoints and ypoints for your chars and counts Set the title to "Scrabble Words Starting Letter Frequency" . Set the xlabel to "Letter" . Set the ylabel to "Frequency" . Create a bar graph using the xpoints and ypoints, and setting the color to whatever color you'd like . You might want to apply labels to the bar graph. Here is how to do that: for i in range(len(xpoints)): pit, text(i, ypoints[i], ypoints[i], ha-'center', va-'bottom') . Now save your graph. You can do that using the savefig method, in either PDF or PNG format. (PDF is a vector format, PNG is rasterized) pit, savefig('wordCount, png' pit, savefig('wordCount, pdf') . Now show the graph: pit, show() . It should look like this (color may vary)

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