Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
7th Apr 2021, 7:04 AM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 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.
7th Apr 2021, 7:12 AM
ChaoticDawg
ChaoticDawg - avatar