Question
IN PYTHON PROGRAMMING Text File 1 . So I have a text file called myFirstSalesRecords which consists of Elsa 0 2 2 260
IN PYTHON PROGRAMMING
Text File 1 .So I have a text file called "myFirstSalesRecords" which consists of
Elsa 0 2 2 260 Cathy 1 0 4 115 Alice 1 7 2 800 Elsa 2 7 2 815 Cathy 2 5 2 605
Text File2. So I have another text file called "myFirstSalesRecords1" which consists of :
David 0 1 1 130 Bob 2 1 0 135 Alice 3 1 3 225 David 3 4 1 490 Cathy 2 4 0 450 Bob 4 2 5 395 Elsa 0 1 3 180 Alice 3 0 5 170 Elsa 3 0 2 95 Elsa 1 4 4 535 Cathy 0 1 3 180 Bob 1 3 5 455 Alice 2 0 1 55 Cathy 2 4 7 625 Alice 0 4 3 495 Alice 3 0 7 220 Bob 3 3 1 385 Cathy 2 3 7 520 Cathy 0 3 7 490 Elsa 0 4 5 545 David 2 1 1 160 David 2 0 3 105 Elsa 4 2 1 295 David 3 3 1 385 David 2 3 7 520 Elsa 2 4 4 550 Elsa 1 2 2 275 David 3 2 7 430 Cathy 4 0 4 160 Bob 3 4 6 615 Bob 1 2 6 375 Bob 1 4 7 610 Elsa 4 0 1 85 Alice 1 0 4 115 Alice 2 2 6 390 Alice 1 1 2 170 Alice 4 3 1 400 David 2 3 3 420 Cathy 1 4 5 560 Bob 3 2 7 430 Bob 0 4 4 520 Alice 0 3 4 415 David 4 2 1 295 Cathy 3 4 0 465 Cathy 0 3 6 465 Cathy 3 3 1 385 David 3 0 7 220 Bob 1 4 2 485 Elsa 4 4 3 555 Cathy 1 1 2 170 Bob 0 0 6 150 Elsa 0 4 1 445 Bob 1 2 0 225 Alice 2 3 6 495 David 4 4 5 605 David 1 4 3 510 Alice 3 0 0 45 David 0 4 7 595 Elsa 0 3 5 440 Elsa 3 3 2 410 Elsa 2 1 7 310 David 4 3 0 375 David 3 3 1 385 Elsa 1 1 7 295 Elsa 0 0 5 125 Cathy 2 0 1 55 David 1 4 0 435 Alice 0 4 6 570 Cathy 1 3 3 405 David 3 3 2 410 Alice 0 2 3 285 Elsa 1 4 5 560 Bob 3 2 0 255 Cathy 0 3 0 315 Alice 1 4 0 435 Alice 1 0 6 165 David 2 0 4 130 Elsa 2 0 7 205 Bob 4 0 0 60 Alice 1 0 6 165 David 0 2 1 235 Elsa 2 4 1 475 Elsa 0 3 2 365 Alice 1 4 6 585 Bob 4 3 1 400 Cathy 4 1 5 290 Elsa 4 4 4 580 Bob 3 2 4 355 Cathy 2 3 2 395 Alice 2 4 1 475 Bob 1 3 6 480 Elsa 2 2 2 290 Cathy 0 1 3 180 Alice 2 0 7 205 Bob 4 4 2 530 Elsa 0 3 1 340 Cathy 4 4 6 630 Bob 0 3 3 390 Alice 3 4 0 465 Cathy 1 2 6 375 David 4 1 7 340 Elsa 2 2 0 240 Cathy 3 1 3 225 Cathy 2 2 4 340 Alice 1 2 3 300 Bob 1 3 4 430 Elsa 4 3 6 525 Cathy 3 0 5 170 Bob 0 1 7 280 Cathy 3 4 5 590 Cathy 0 3 2 365 David 1 2 7 400 Alice 4 1 3 240 David 3 3 4 460 Elsa 3 3 0 360 Bob 2 1 2 185 David 1 1 0 120 Cathy 4 1 4 265 Cathy 3 2 4 355 Cathy 2 2 4 340 David 0 2 7 385 Elsa 0 1 2 155 Alice 2 0 1 55 David 2 3 4 445 David 2 1 3 210 David 2 2 1 265 Alice 3 1 7 325 David 2 0 5 155 Cathy 1 2 7 400 Alice 1 2 5 350 David 3 0 6 195 David 1 3 4 430 David 3 3 3 435 Bob 1 3 2 380 Alice 1 0 2 65 David 0 1 6 255 Alice 1 4 2 485 David 3 3 0 360 Alice 3 1 3 225 Bob 1 4 1 460 Cathy 0 4 3 495 David 1 4 5 560 Cathy 1 0 1 40 Elsa 0 2 2 260 Elsa 1 3 2 380 David 3 1 4 250 Cathy 0 2 1 235 Alice 2 1 7 310 Alice 3 2 4 355 David 2 4 5 575 David 3 2 3 330 Bob 0 0 4 100 David 3 1 1 175 Cathy 0 1 5 230 Cathy 0 2 2 260 David 1 1 0 120 Alice 2 0 6 180 Alice 0 4 5 545 Alice 4 2 1 295 Alice 1 2 6 375 Bob 1 3 1 355 Bob 0 2 7 385 David 2 0 6 180 David 4 4 6 630 Elsa 4 0 3 135 Cathy 0 3 6 465 Alice 0 2 4 310 Bob 3 3 0 360 Bob 4 2 0 270 David 0 0 4 100 David 2 2 1 265 Bob 3 1 1 175 Cathy 1 0 5 140 Alice 3 3 4 460
in this structure
Purchase #1 Customer Name
Purchase #1 Number of Hats
Purchase #1 Number of Coats
Purchase #1 Number of Wands
Purchase #1 Total Cost
Purchase #2 Customer Name
Purchase #2 Number of Hats
Purchase #2 Number of Coats
Purchase #2 Number of Wands
Purchase #2 Total Cost ...etc...
Questions
Create a file called myrecords.py. You will add all the functions you create as part of this assignment to this file. All function names and arguments must match the specifications.
1. Write a function named 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 been stored in that file (that is, the total number of orders, not the total number of products).
Add another function to the myrecords.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 been stored in that file (that is, the sum of the last lines of each purchase record).
Add another function to the myrecords.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 been stored in that file.
Add another function to the myrecords.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 myrecords.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 myrecords.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.
Add a final function to the myrecords.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 (Hat, Coat, or Wand). In the case of a tie, your function can return any of the highest selling products.
Note: You are allowed to write one or more helper functions if necessary. You can always try to generalize some of your functions to eliminate duplicated code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started