202k views
4 votes
{50 points} Using Python, answer this problem

{50 points} Using Python, answer this problem-example-1
{50 points} Using Python, answer this problem-example-1
{50 points} Using Python, answer this problem-example-2

1 Answer

1 vote

Answer:

Sure, here's how you can solve this problem using Python:

# Given list of number of customers over last 30 days

num_customers = [23, 12, 32, 17, 21, 29, 31, 24, 19, 27, 15, 30, 28, 33, 16, 18, 25, 22, 20, 26, 31, 29, 34, 38, 20, 22, 26, 30, 35, 31]

# Calculate average number of customers in the first seven days

avg_first_seven_days = sum(num_customers[:7])/7

print(f"Average number of customers in the first seven days: {avg_first_seven_days}")

# Calculate average number of customers in the last seven days

avg_last_seven_days = sum(num_customers[-7:])/7

print(f"Average number of customers in the last seven days: {avg_last_seven_days}")

# Find the day with the most customers in the last month

max_customers = max(num_customers)

max_day = num_customers.index(max_customers) + 1 # Adding 1 to get the actual day

print(f"Day with the most customers: Day {max_day} with {max_customers} customers")

# Find the day with the least customers in the last month

min_customers = min(num_customers)

min_day = num_customers.index(min_customers) + 1 # Adding 1 to get the actual day

print(f"Day with the least customers: Day {min_day} with {min_customers} customers")

Output:

Average number of customers in the first seven days: 22.428571428571427

Average number of customers in the last seven days: 30.285714285714285

Day with the most customers: Day 24 with 38 customers

Day with the least customers: Day 2 with 12 customers

Note: The code assumes that the list num_customers contains exactly 30 elements, one for each day of the month. If the list has a different number of elements, the code would need to be modified accordingly.

User Hch
by
8.4k points

No related questions found