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
- Im looking for the answers to the Walt Disney Company's Sleeping Beauty Bonds— Duration Analysis
- I need answers for those questions please. 1.King's letter was written in response to a published statement by eight white clergymen (see p. 109). What
- Comment sont les étudiants de votre université? sérieux/sérieuses intelligents/intelligentes nerveux/ nerveuses amusants/amusantes Ils sont (blank). Ils