+ 1

Can anyone please help me with this solving this code in Python. I tried a lot but it's not going well.

# I want to calculate and output the percentage of houses that are within one standard deviation from the mean. p = [150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000] import numpy as np a=a = np.array([150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000]) mean =np.sum(a)/a.size variance=np.sum((a-mean)**2)/a.size sd=np.sqrt(variance) j=mean-sd h=mean+sd n=[] for i in range (len(p)): if a[i]<h and a[i]>j: n.append(p[i]) m=len(n) k=(m/a.size)*100 print(K) p

20th May 2022, 12:53 PM
Rahma HEJJA
Rahma  HEJJA - avatar
5 Antworten
+ 1
Can you post full task description? If ranges are includive use <=, >= in place of <, > is answer 62.5 ?
20th May 2022, 2:00 PM
Jayakrishna 🇮🇳
+ 1
Try Print m instead of k. is j, h are not inclusives?
20th May 2022, 12:56 PM
Jayakrishna 🇮🇳
+ 1
Thanks for your response I print k because they asked to output the percentage not the number j,h are used to mention the condition
20th May 2022, 1:46 PM
Rahma HEJJA
Rahma  HEJJA - avatar
+ 1
You are given an array that represents house prices. Calculate and output the percentage of houses that are within one standard deviation from the mean.
20th May 2022, 3:14 PM
Rahma HEJJA
Rahma  HEJJA - avatar
+ 1
This is the full task decription
20th May 2022, 3:14 PM
Rahma HEJJA
Rahma  HEJJA - avatar