Você está na página 1de 2

CSCE 101 Assignment #5: Plotting Inventory Stock

Due Monday, April 4, 11:59pm, via CSE handin.


1. Modify the main program for Assignment #4, inventorySystem.py, by adding three lines:
from inventoryPlot import plotInventory
# Plot the inventory for each item from itemRecords
plotInventory(itemRecords)
The last line calls a function plotInventory(), which you will write.
2. Create a file inventoryPlot.py.
a. In this file, you must import the stockItem class definition from inventoryClass.py,
which you completed for Assignment #4:
from inventoryClass import stockItem
b. In this file, you also must import numpy and pyplot, e.g.:
import numpy as np
import matplotlib.pyplot as plt
c. In this file, define the function plotInventory(), with the interface:
def plotInventory(itemRecords) :
d. Complete the function plotInventory() so that it creates a bar plot to show the start
and end inventory stock for each item. Figure 1 shows an example that was created
by modifying code from the bar chart demonstation program at:
http://matplotlib.org/examples/api/barchart_demo.html
Note many changes, including the difference in data, title, x-axis tick labels, y-axis
label, legends, colors, and x-axis spacing. Note that the items are ordered by item
ID. You need not copy these stylistic changes, but you must create a plot that shows
the required information and you will be graded on visual style.
For submission, you must:

Complete the file inventoryPlot.py as described above with four lines of comments at
the top of your program, e.g.:
# Author: <yourName>
# Course: CSCE 101
# Assignment: 5 Plotting Inventory Stock
# Date: <yourDate>
Save the plot for the example data to a PNG-format image file named
<yourName>5.png.
You must use handin to submit your Python program and PNG file with the specified names.
Figure 1. Example plot of item inventories.

Grading Rubric
Required Elements:
Submitted program (30 points).
Program executes without run-time error (maximum 20 points).
Program creates a bar chart for the example data (maximum 25 points).
Program generates correct plots for test data (maximum 25 points).
Stylistic Elements:
Comments, sections, organization, brevity, readability, output formatting, etc. (between
10 and +10 points).
Total: Maximum 110 points.

Scores should reflect the following subjective scale:


>100 Exceptional.
>=90 Outstanding.
>=80 Good.
>=70 Acceptable.
>=60 Poor.
<60 Unacceptable.

Você também pode gostar