- 1

You are given an array that represents house prices.Calculate and output the percentage of houses that are within one standard..

.. deviation https://code.sololearn.com/cYwov5ghhYf8/?ref=app

7th Aug 2021, 5:33 AM
Saurabh Maurya
Saurabh Maurya - avatar
4 Answers
+ 4
import numpy as np data = np.array([150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000]) mean=data.mean() stdv=data.std() low=mean-stdv high=mean+stdv # count of the all in range prices count=len([i for i in data if low < i < high ]) #calculating percentage print(count*100/len(data))
9th Aug 2021, 12:06 PM
Ratnapal Shende
Ratnapal Shende - avatar
0
import numpy as np data = np.array([150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000]) mean = data.mean() stdv = data.std() low = mean-stdv high = mean+stdv x = [] data = data[(data<=high) & (data>low)] #16 houses #calculating percentage print((len(data)/16)*100)
21st Jun 2022, 10:24 AM
Ssembatya Moses
Ssembatya Moses - avatar
0
import numpy as np data = np.array([150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000]) mean = np.mean(data) stdev = np.std(data) old = mean - stdev new = mean + stdev cnt = 0 for p in data: if p> old and p < new: cnt += 1 per = cnt/len(data) *100 print(per)
4th Sep 2022, 10:33 AM
Pradip Gubhaju
Pradip Gubhaju - avatar
0
data = np.array([150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000]) tot=sum(data) itung=len(data) rata=tot/itung devi=np.std(data) lowstd=rata-devi higstd=rata+devi kun=0 for i in data: if i>lowstd and i<higstd: kun+=1 persenan = (kun/itung)*100 print(persenan)
17th Sep 2022, 9:42 AM
Agnes Martha