Code coach basketball player | Sololearn: Learn to code for FREE!

+5

Code coach basketball player

Can someone please explain this question And what's wrong in this solution import numpy as n players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] arr=n.array(players) x=arr[arr>arr.std()] x=x[x<arr.mean()] print(x.size)

4/7/2021 5:42:40 AM

😴 Wake Up πŸ’€

5 Answers

New Answer

+5

See according to the question You need to calculate how many players are in the range of one standard deviation from the mean. And the range of one standard deviation from the mean means the range from ((Mean - standard deviation ) , (Mean+ standard deviation)). See I did some changes in ur code . Now I just used that range formula there: https://code.sololearn.com/c4NREZQX7I8A/?ref=app

+5

✨Kårï§hmå✨ thanks sista Can you please explain this question?

+5

✨Kårï§hmå✨ thank you very much sista

+5

Although flipping the sign ends up resulting in the same number of elements in the final array, they aren't the correct elements and the suggested answer is incorrect. This line; x=arr[arr>arr.std()] Just ends up copying the original array to the variable x, since all values in the original array are greater than the standard deviation of the array. The next line, when corrected as suggested; x=x[x>arr.mean()] creates a new array of all the values in x that are greater than the mean value of all the elements in x, and saves them back into the x variable. There just happens to be 6 values (x.size) that meet this condition. What is intended is for you to find all the values that are within the mean ± the standard deviation. So, if the mean were 180 and the standard deviation were 10 you would get all the numbers in the array from 170-190 and output the count. Edit: didn't see ✨Kårï§hmå✨ second answer which is correct. Except, the use of the range() function, which could error as it only works with integers.

+3

ChaoticDawg thanks for better explanation