FAQ: Introduction to Statistics with NumPy - NumPy and Mean

This community-built FAQ covers the “NumPy and Mean” exercise from the lesson “Introduction to Statistics with NumPy”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Introduction to Statistics with NumPy

FAQs on the exercise NumPy and Mean

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’m lost as to how to answer Question #3 for this exercise:
"The boss says that we should increase what we stock, but only if the store’s average sales are greater than 7 bottles per week.

Save the store dataset variable name that fits this description to the variable best_seller ."

How do you associate a store name with the value where the store average is greater than 7 in NumPy? i’m so stuck.

best_seller = store_two

1 Like

Code challenge:
Write a function that will automatically detect best seller.


I agree, the question is misleading it states:

Save the store dataset variable name that fits this description to the variable best_seller .

That to me indicates the actual name of the variable, not the array of data. Remove the text “variable name” from the instructions.

actually still i am worry how to write the code to answer that question automatically

if store_one_avg > 7:
  best_seller = store_one
  print('Best seller is store one')
if store_two_avg > 7:
  best_seller = store_two
  print('Best seller is store two')
if store_three_avg > 7:
  best_seller = store_three
  print('Best seller is store three')

i;'m sure there's a better why to write it using a loop, but i'm pretty new. The question asked for stores that have an average of more than 7, so that might be more than one.
for x in ['a', 'b', 'c']:
    if condition:
        print("Condition fulfilled by {}".format(x)) 
> store_dataset = [[store_one, store_one_avg], [store_two, store_two_avg], [store_three, store_three_avg]]
> for i in store_dataset:
>   if i[-1] > 7.0:
>     best_seller = i[0]

My solution is

best_seller = ([store_one,store_two,store_three][[store_one_avg,store_two_avg,store_three_avg]>7])

The wording of Question 3 is pretty confusing. It is difficult to interpret what you want us to do