Question: For python This project will store the volume of sales for a particular product for a sequence of days. It could be for a week,
For python
This project will store the volume of sales for a particular product for a sequence of days. It
could be for a week, or a month. We are not going to worry about what we are selling, or the
cost just the number of items sold on each day. This should be able to work for any number of
days every month doesnt have the same number of days. To keep it shorter for this
assignment, my example will only worry about days. We will only address the total quantity
sold each day.
Since the sales may not be reported in order, we need to create space for all the possible days
at the beginning of the program. This will be done in the createList function. We wont
necessarily have all the sales totals turned in all at once, so we need to be able to differentiate
between no actual sales and the number of sales for the days not having been turned in yet.
Since is possible for the number of items sold, we cant initialize each item to With that in
mind, initialize each item in the list to when the list is created.
Remember that the indexes of the actual list will be based, where people tend to create
based lists. All functions that accept a day will accept a based value. It is important when
programming to write functions that work with the nomenclature of the person using your code,
and days are based.
We will need to be able to answer some questions about the sales for each of the days. To
do so write each of the following functions. The function header must be implemented exactly
as specified. You can change the name of the parameters, but not the order or functionality of
any parameters.
Write a main function that tests each of your functions.
Required Functions
createList days creates a list of the specified size, initializes each value in the list to
and returns the list.
setSales salesList day, numOfSales If day is valid the function sets the sales for the
specified day and returns True. If day is not valid, do nothing to the list and return False.
getSales salesList day returns the quantity of sales for the specified day. If day is not
valid, return None.
totalSales salesList returns the total quantity of sales. Only return the summation of
items where the number of sales have been reported.
numOfDaysWithSale salesList returns the total number of days with a reported sale.
This DOES NOT return the number of total products or the total sales.
numOfDaysWithNoSale salesList returns the total number of days where a sales amount
was provided, yet nothing was sold. A day unreported sales IS NOT a day with no sales. This
DOES NOT return the number of total products or the total sales.
bestDay salesList returns the day with the highest number of sales. You can safely
assume that there will be a single day that was the best day.
worstDay salesList returns the day with the lowest number of sales. You can safely
assume that there will be a single day that was the worst day.
getAverage salesList this function returns the average number of items sold. This value
will not include days where there has not been reported sales. This function should use the
totalSales and numOfDaysWithSale functions, DO NOT duplicate the work already done in
those functions. Return None if you are unable to calculate the average.
printSales salesList this function DOES create output on the display. Print out the day
the users numbers through XX and the total number of sales for that day, IF there was a
sale that day. If there were no sales that day, leave the quantity blank. Create columns, with
each value right justified. Print an appropriate label above each column. The maximum number
of days in the list will be ; this will be useful for formatting the table. Do not return anything
from the function.
A brief example of using these functions might look like what follows. Note the example is
typed, not actual code, so there may be minor syntax errors. Ask about something if you are not
sure about the intent.
sales createItems #creates a list of values, and sets all of them to
setSales sales
setSales sales
itemsSold totalSales sales # should return
daysWithASale numOfDaysWithSale sales # should return
avgPerDay getAverage sales # should return
printSales sales
Day Sales
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
