COMP 1005/1405A – S19 – A3 Due Saturday, June 1st at 11:59 PM 1 Assignment 3 Files and Functions Submit a single zip file called assignment3.zip. This assignment has 50 marks. See the marking scheme...

1 answer below »
Assignment with three problems. All description in the files.


COMP 1005/1405A – S19 – A3 Due Saturday, June 1st at 11:59 PM 1 Assignment 3 Files and Functions Submit a single zip file called assignment3.zip. This assignment has 50 marks. See the marking scheme that is posted on the course webpage. Assignment Background In the previous assignment, you developed an ordering system for an electronics store. If we had covered files at that time, your solution could have saved sales information for the store to track all transactions. For this assignment, we will assume that somebody has added that functionality and generated several files recording sales information for different time periods. You will develop a module for performing some sales analysis by processing these files. For the purposes of this assignment, you should assume that each order saved to a file will consist of 6 lines of information in the following pattern: Customer Name, Number of Desktops Purchased, Number of Laptops Purchased, Number of Tablets Purchased, Number of Toasters Purchased, Total Cost of Purchase. A single file will consist of many orders, resulting in a file with the structure: Purchase #1 Customer Name Purchase #1 Number of Desktops Purchase #1 Number of Laptops Purchase #1 Number of Tablets Purchase #1 Number of Toasters Purchase #1 Total Cost Purchase #2 Customer Name Purchase #2 Number of Desktops Purchase #2 Number of Laptops Purchase #2 Number of Tablets Purchase #2 Number of Toasters Purchase #2 Total Cost …etc… The functions you write for this assignment must work with any file that follows this format, regardless of the number of orders contained in the file. You do not need to create the files. You can use the test files posted on cuLearn along with the sales-stats-tester.py file to see if your code is producing the correct values. You should read through the entire assignment first and plan accordingly. If you approach this problem correctly, you will not have to write a lot of code. Note: Your module should only have function code. There should be no print statements and no code outside of the function definitions. COMP 1005/1405A – S19 – A3 Due Saturday, June 1st at 11:59 PM 2 Problem 1 (Total Sales Statistics) Create a file called a3.py, which you will use for all the functions you create as part of this assignment. The first function you write must be called get_number_purchases(filename). This function must process the file with the name specified in the filename argument and return an integer representing the total number of purchases that have occurred (that is, the total number of orders, not the total number of products). Add another function to the a3.py file called get_total_purchases(filename). This function must process the file with the name specified in the filename argument and return the total cost of all purchases that have occurred (that is, the sum of the last lines of each purchase record). Add another function to the a3.py file called get_average_purchases(filename). This function must process the file with the name specified in the filename argument and return the average cost of all purchases that have occurred. Problem 2 (Customer Sales Statistics) Add another function to the a3.py file called get_number_customer_purchases(filename, customer). This function must process the file with the name specified in the filename argument and return an integer representing the number of purchases that have been made by a person with the name specified in the customer argument. Add another function to the a3.py file called get_total_customer_purchases(filename, customer). This function must process the file with the name specified in the filename argument and return the total cost of all purchases that have been made by a person with the name specified in the customer argument. Add another function to the a3.py file called get_average_customer_purchases(filename, customer). This function must process the file with the name specified in the filename argument and return the average cost of all purchases that have been made by a person with the name specified in the customer argument. Problem 3 (Product Sales Statistics) Add a final function to the a3.py file called get_most_popular_product(filename). This function must process the file with the name specified in the filename argument and return a string value representing the product that sold the highest number of units (“Desktop”, “Laptop”, “Tablet”, or “Toaster”). In the case of a tie, your function can return any of the highest selling products. Note: If it makes it easier to program, you can assume that no customer will ever have the name “*”. It may be worth thinking about how this could allow you to generalize some of your functions and eliminate duplicated code. Functions (6 Marks Each, 42 Total) 1 - Correct definition 1 - works without errors 4 - Returns correct values General Coding Style (8 marks) Good variable names Minimal duplicated code Comments explaining functions and process Adrian 4 0 2 3 4855 Pascal 3 2 0 3 5255 Adrian 0 0 0 1 85 Carlo 4 1 2 1 5910 Emma 3 1 1 3 4630 Steve 0 7 0 2 8745 Pascal 1 4 6 1 9435 Pascal 1 4 7 1 10035 Carlo 3 5 6 2 12445 Jess 3 4 1 1 8135 Jess 1 4 6 1 9435 Adrian 4 6 6 1 14435 Emma 4 3 7 2 11445 Allana 0 7 5 1 11660 Jarvis 4 6 6 0 14350 Jarvis 0 7 7 2 12945 Carlo 3 3 1 0 6825 Carlo 0 1 0 2 1395 Larry 0 2 6 1 6135 Dave 4 1 3 2 6595 Adrian 4 0 0 1 3485 Emma 1 2 5 2 6470 Jess 2 3 0 0 5375 Pascal 4 2 5 2 9020 Adrian 4 5 7 2 13895 Adrian 2 3 4 1 7860 Carlo 0 1 6 0 4825 Jarvis 1 5 0 0 6975 Steve 0 3 5 0 6675 Emma 1 0 4 1 3335 Chloe 4 4 2 0 9500 Adrian 1 2 0 1 3385 Carlo 4 5 3 0 11325 Jarvis 1 6 4 2 10770 Azim 4 4 2 0 9500 Steve 2 7 5 1 13360 Larry 0 1 0 1 1310 Azim 1 6 6 0 11800 Adrian 3 4 1 0 8050 Pascal 2 4 4 1 9085 Dave 3 2 5 2 8170 Adrian 2 1 2 0 4125 Allana 1 2 2 2 4670 Pascal 1 6 7 2 12570 Carlo 4 2 0 2 6020 Abdul 2 0 1 1 2385 Azim 0 1 4 2 3795 Emma 2 5 3 1 9710 Steve 2 6 5 0 12050 Carlo 2 3 0 1 5460 Allana 0 0 6 1 3685 Jess 1 1 0 2 2245 Abdul 3 4 2 0 8650 Steve 0 2 4 2 5020 Larry 0 2 6 1 6135 Dave 1 7 4 1 11910 Pascal 1 6 3 2 10170 Steve 2 3 3 2 7345 Jess 0 3 7 2 8045 Jess 1 5 1 0 7575 Jess 0 4 6 2 8670 Jess 2 7 6 1 13960 Emma 2 0 2 2 3070 Azim 4 6 3 1 12635 Pascal 1 7 5 0 12425 Dave 1 1 7 1 6360 Azim 0 3 5 1 6760 Jarvis 4 5 3 2 11495 Dave 1 5 4 2 9545 Abdul 3 3 0 0 6225 Pascal 3 6 5 0 12900 Emma 3 2 4 1 7485 Adrian 3 2 3 2 6970 Jarvis 3 1 0 0 3775 Adrian 0 5 6 1 9810 Adrian 1 0 2 2 2220 Dave 1 2 5 1 6385 Carlo 1 4 2 0 6950 Dave 1 0 0 2 1020 Larry 3 5 1 1 9360 Allana 2 6 6 0 12650 Chloe 4 2 4 1 8335 Pascal 2 0 0 0 1700 Allana 4 3 2 0 8275 Adrian 4 4 4 2 10870 Pascal 0 3 5 2 6845 Emma 3 1 6 2 7545 Carlo 3 6 0 2 10070 Larry 4 7 2 0 13175 Jess 2 5 6 2 11595 Jarvis 3 2 7 2 9370 Allana 0 5 1 1 6810 Jess 4 3 1 0 7675 Jarvis 1 3 7 2 8895 Allana 2 3 6 1 9060 Azim 3 6 3 1 11785 Abdul 4 4 0 2 8470 Allana 1 3 3 2 6495 Larry 0 6 2 1 8635 Allana 4 7 6 2 15745 Emma 0 2 5 2 5620 Dave 2 2 5 2 7320 Chloe 0 0 2 1 1285 Abdul 4 4 0 1 8385 Chloe 2 0 6 1 5385 Abdul 0 5 6 0 9725 Dave 4 0 1 2 4170 Carlo 2 2 2 0 5350 Steve 4 6 0 0 10750 Larry 2 6 6 1 12735 Azim 1 4 1 1 6435 Pascal 2 2 5 0 7150 Emma 3 6 3 0 11700 Larry 4 5 5 2 12695 Allana 2 3 7 1 9660 Abdul 4 4 7 1 12585 Chloe 4 5 0 2 9695 Jarvis 2 7 2 2 11645 Dave 3 3 7 0 10425 Allana 0 4 2 0 6100 Jess 1 5 5 0 9975 Carlo 1 5 2 1 8260 Jess 4 7 6 2 15745 Steve 3 5 2 1 9960 Carlo 0 0 3 1 1885 Allana 0 3 1 1 4360 Jarvis 1 0 3 2 2820 Adrian 4 7 2 1 13260 Steve 0 1 3 1 3110 Emma 4 4 1 2 9070 Pascal 3 1 2 2 5145 Adrian 2 4 4 2 9170 Emma 1 5 1 2 7745 Abdul 3 3 1 0 6825 Jess 4 6 6 2 14520 Abdul 2 0 2 1 2985 Azim 2 1 3 1 4810 Chloe 3 6 2 1 11185 Azim 1 0 3 0 2650 Jarvis 1 1 4 2 4645 Emma 4 4 4 0 10700 Larry 0 6 6 1 11035 Carlo 1 4 0 0 5750 Abdul 0 7 3 1 10460 Jarvis 0 6 4 2 9920 Steve 4 7 6 0 15575 Dave 2 6 2 0 10250 Allana 2 5 7 2 12195 Abdul 2 4 0 1 6685 Azim 2 2 0 1 4235 Steve 4 0 5 1 6485 Jarvis 3 2 6 2 8770 Jess 3 5 6 1 12360 Emma 3 6 3 2 11870 Dave 1 3 2 1 5810 Emma 2 6 2 2 10420 Dave 2 3 7 1 9660 Steve 0 0 7 2 4370 Emma 4 4 3 0 10100 Jarvis 2 5 1 2 8595 Jess 1 3 4 0 6925 Azim 3 1 7 0 7975 Pascal 2 0 1 2 2470 Carlo 1 5 0 0 6975 Jess 0 0 6 2 3770 Adrian 4 1 7 2 8995 Emma 3 6 1 1 10585 Chloe 3 4 0 1 7535 Adrian 0 2 4 0 4850 Adrian 3 6 0 1 9985 Emma 1 7 5 0 12425 Azim 2 6 6 2 12820 Larry 2 0 2 2 3070 Dave 3 7 6 2 14895 Adrian 0 6 2 1 8635 Adrian 3 0
Answered Same DayMay 29, 2021COMP1005

Answer To: COMP 1005/1405A – S19 – A3 Due Saturday, June 1st at 11:59 PM 1 Assignment 3 Files and Functions...

Pritam answered on May 30 2021
160 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here