all exercises are 10 points each
Exercise 1
sales.txt is a file provided in the homework section for this week. It is tab delimited and has order number, the number of products purchased on that order, and the profit earned on that order.
Write a script that reads the file and prints out:
- The order number that had the greatest number of items ordered
- The order number that earned the most profit
You must calculate the answers in your script (e.g. you can't just go through the file yourself, find the answer, and write a script that prints those numbers out). Your output should look like this (note that these are made up values to show format and not the correct values):
Order with most products: 188939527
Order with most profit:1938882
Exercise 2
Using the sales data from above, write a script that has two dictionaries, one for number of items ordered and one for profit earned. Use the order number for the key in each dictionary. Using pickle, dump the dictionaries into a single file. You MUST dump the dictionary for number of products ordered first and the dictionary for profit second. Submit your python script AND your output file.
YOU MUST HAVE ONLY ONE OUTPUT FILE THAT STORES BOTH DICTIONARIES.
Exercise 3
Write a script that will load the two dictionaries from an Exercise 2 output file. Then, using the dictionaries, print the average number of products ordered per order and the average profit per order. Your script will be tested on other people's Exercise 2 output and your Exercise 2 output will be tested with other people's scripts. Your output should look like this (note that these are made up values to show format and not the correct values):
Average products per order: 3.1
Average profit per order: 1.2