- 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
4 odpowiedzi
+ 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))
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)
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)
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)