Use a list of lists to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day,
each salesperson passes in a slip for each different type of product sold. Each slip contains:
a) The salesperson number.
b) The product number.
c) The number of that product sold that day.
Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that the information from all of the slips for last week is available.
Write a program that will read all this information for last month’s sales and summarize the total sales by salesperson by product.
All totals should be stored in list sales. After processing all the information for last week, display the results in tabular format, with each of
the columns representing a particular salesperson and each of the rows representing a particular product. Cross-total each row to get the total sales
of each product for last
week; cross-total each column to get the total sales by salesperson for last week. Your tabular printout should include these cross-totals to the right
of the totaled rows and at the bottom of the totaled columns.
Example use of list of lists:
The above represents 4 slips’ data.
The first item in a sublist is sales person id
The second item in a sublist is the product id
The third item in a sublist is the number of items sold
The number 10 above represents the number of items sold by sales ID 1 for product ID 4.
Note that the elements of a sublist can be accessed by using  with proper index values. All of the list commands are also applicable for sublists too.
Recently Asked Questions
- 1.A multi‐bay building that is supported on reinforced concrete foundation piles is to be demolished and replaced with a new building that will use the
- Explain the issues you will raise, and who will you speak to, as you clarify the limits of your responsibilities as project manager
- what would be a good response to this? The speech I chose was Franklin Delano Roosevelt's "The Great Arsenal of Democracy" speech. This was an incredibly