CSCI-UA.0002 - Python - Summer 2017

ASSIGNMENT 11

Due: Thursday August 10th


Choose a type of store which you want to manage (grocery, drug store, electronics store, chess, ballet, etc., etc.). Then, write a program which manages your store's stock room which is represented by a dictionary. First, start with a dictionary that has at least ten items in it and their associated stock_on_hand. For example, you might "hard code" the following data:

Of course, you can have anything in your store you want. Note that the product name MUST be only one word, although numbers and the "_" can be used.

Then, from the keyboard, input a series of products and their respective counts - which can either be positive or negative. If the product exist in the dictionary already, update the stock by that amount. If the product does NOT exist, add it to the dictionary and set its stock_on_hand to be that of the input. Reject inputs which would put your stock into the negative. Delete dictionaries entries when their stock falls to 0.

This part of the run might look something like this:

Input product name and count, separated by a space or 'STOP": DVR 10

Input product name and count, separated by a space or 'STOP": iPhone_8 -1

Input product name and count, separated by a space or 'STOP": TV -88

Input product name and count, separated by a space or 'STOP": TV 4

Input product name and count, separated by a space or 'STOP": Turntable -3

Input product name and count, separated by a space or 'STOP": Ray_Gun 50

Input product name and count, separated by a space or 'STOP": Mac-Watch 100

Input product name and count, separated by a space or 'STOP": STOP

Note that each line of input is a single string separated by a space from an integer number.

Print out dictionary, printing both the product name (in alphabetical order - aka, sorted) and stock_on_hand for each item. From the above data, this output might look like:

THE ELECTRONICS BOUTIQUE - STOCK ON HAND

DVR - 21

Ethernet_Cable - 53

Flash_Drive - 213

Google_Pixel - 26

Hard_Drive - 199

iPhone_8 - 96

Mac_Watch - 200

Ray_Gun - 50

Remote_Control - 12

TV - 4

Note that "Turntable" isn't printed since it has been deleted.

When you are done and have tested it, post your source file "smith_john_assign11" on "NYU Classes"