Question

In: Computer Science

You have a theory that certain days of the week are most likely to be the...

You have a theory that certain days of the week are most likely to be the highest sales You are to write a program that will test that theory.

Write a program that will have a list of 52 lists, each of those 52 lists must be of length 7 (that is they will each accommodate 7 items). Think of 52 weeks with 7 days in each week. Save a random value from 70 - 100 (inclusive of 70, exclusive of 100) in each of the days of each of the weeks.

Your code should analyze the list above and print a list of the number of times each day of the week had the highest sales. If more than one day had the highest sales of the week I do not care which of those days is recorded as the highest sales day.

Here is an example of the expected output: note that in the example below I generated and analyzed 5 weeks, you are to generate and analyze 52 weeks:

My code generated and output the following list of lists:

[[93, 98, 95, 75, 81, 88, 97], [91, 76, 81, 84, 72, 97, 83], [91, 81, 75, 72, 92, 95, 79], [98, 93, 88, 74, 93, 97, 82], [77, 86, 90, 87, 75, 84, 95]]

And output the following list after analysis of the above list:

[1, 1, 0, 0, 0, 2, 1]

The actual output from running my code was:

RESTART: /Users/janetbrownsederberg/Stonehill/Stonehill_Fall2020/HighestSales.py

[[93, 98, 95, 75, 81, 88, 97], [91, 76, 81, 84, 72, 97, 83], [91, 81, 75, 72, 92, 95, 79], [98, 93, 88, 74, 93, 97, 82], [77, 86, 90, 87, 75, 84, 95]]

[1, 1, 0, 0, 0, 2, 1]

>>>

Please have your output in the form above.

Please done in Python format

Solutions

Expert Solution

'''
Assumption : If sale value is more than 98 than than it
is counted as highest sales

Algorithm :
1. Creating a list of 52x7 using random module.
   random.randint(70,10) is used to generate a random number
    between 70 to 100 including 70 and 100

2. Transpose the list (by using help of numpy array) i.e.
   Transpose it from 52x7 to 7x52.
3. Count the number of times each day of the week had
   the highest sales.
4. Append this counting into the result list.
5. Print the result.
'''
#Anjeev Singh
#10-01-2020

import random
import numpy as np


sales=[]                                        # empty list for sales

for n in range(52):
    week=[]                                     # empty list for week
    for t in range(7):
        week.append(random.randint(70,100))     # generate a random number and append to list.
    sales.append(week)                          # appending week to sales list


arr = np.array(sales).T                         # creating an array with the help of list sales and stores it transpose

lisales = arr.tolist()                          # converting an array to list

highest_sales = [98,99,100]                     # Assume highest sales values

maxsale = []                                    # empty, to store frequency of max sale.

for i in range(7):
    n = max(lisales[i])
    print(lisales[i])
    c = 0
    if n >= 98:
        for n in range(3):
            c += lisales[i].count(highest_sales[n])
        
    else:
        c = 0
    maxsale.append(c)

print("--------------")

print(sales)

print("--------------------")

print("after analysing ")

print(maxsale)
    

Note : above solution is given as per your explanation given in question paper. you have not clarify any conditions for assuming maximum sales of a day.

All the best.


Related Solutions

What event is most likely to have a negative impact on the Accounts Payable days and...
What event is most likely to have a negative impact on the Accounts Payable days and a positive impact on profits? a. Supplier tightens terms. b. Use supplier discounts. c. Controller slows payments. d. Interest rate increases.
The HR department of a certain corporation wants to know if some days of the week...
The HR department of a certain corporation wants to know if some days of the week had more workers call in sick than others. 100 sick day reports are randomly selected. Test the claim that sick days occur with the same frequency on every day of the week using a 0.05 significance level. Day Mon Tue Wed Thu Fri # of sick calls 22 15 17 16   30
Compare and contrast theories of crime causation. Speculate as to which theory would have most likely...
Compare and contrast theories of crime causation. Speculate as to which theory would have most likely detected fraud at Enron. Assess the six situational categories that cause non-sharable problems. Determine which of these six categories, in your opinion, were prevalent at Enron.  
deshiscence is most likely to occur how many days post-operatively?
deshiscence is most likely to occur how many days post-operatively?
Choose one of the middle-range theories. What impact would this theory most likely have on your...
Choose one of the middle-range theories. What impact would this theory most likely have on your individual practice? Give specific examples.
Among the flatworms (tapeworms and flukes) we learned this week, which disease would you most likely...
Among the flatworms (tapeworms and flukes) we learned this week, which disease would you most likely acquire based on your own lifestyle? What could you do to prevent the infection? If you believe you are not at risk of any of these diseases, please explain why.
Consider the following precedence chart: ACTIVITY PRECEDING ACTIVITIES OPTIMISTIC TIME (days) MOST LIKELY TIME (days) PESSIMISTIC...
Consider the following precedence chart: ACTIVITY PRECEDING ACTIVITIES OPTIMISTIC TIME (days) MOST LIKELY TIME (days) PESSIMISTIC TIME (days) A - 5 10 15 B - 10 12 14 C - 10 10 10 D B,C 2 4 6 E A 4 8 12 F A 4 8 12 G D,E 10 12 14 I F 4 8 12 J G 2 4 6 The total slack for activity C is __________
Consider the following precedence chart: ACTIVITY PRECEDING ACTIVITIES OPTIMISTIC TIME (days) MOST LIKELY TIME (days) PESSIMISTIC...
Consider the following precedence chart: ACTIVITY PRECEDING ACTIVITIES OPTIMISTIC TIME (days) MOST LIKELY TIME (days) PESSIMISTIC TIME (days) A - 5 10 15 B - 10 12 14 C - 10 10 10 D B,C 2 4 6 E A 4 8 12 F A 4 8 12 G D,E 10 12 14 I F 4 8 12 J G 2 4 6 The total slack for activity C is __________ a. 0 b. 2 c. 8 d. 4
Consider the following precedence chart: ACTIVITY PRECEDING ACTIVITIES OPTIMISTIC TIME (days) MOST LIKELY TIME (days) PESSIMISTIC...
Consider the following precedence chart: ACTIVITY PRECEDING ACTIVITIES OPTIMISTIC TIME (days) MOST LIKELY TIME (days) PESSIMISTIC TIME (days) A - 5 10 15 B - 10 12 14 C - 10 10 10 D B,C 2 4 6 E A 4 8 12 F A 4 8 12 G D,E 10 12 14 I F 4 8 12 J G 2 4 6 The total slack for activity F is __________ a. 8 b. 4 c. 2 d. 0
For the coming year you have determined that the following possibilities are most likely for stock...
For the coming year you have determined that the following possibilities are most likely for stock A: Economic State Probability Return Good 0.60 12 Bad 0.40 -2 What is the expected return for stock A?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT