Python da Frekans ve Mod alma işlemi
In [1]:
def frekans(liste):
frekanss = {}
for i in liste:
frekanss[i] = liste.count(i)
return frekanss
def mode(frekanss):
liste=[]
for deger in frekanss:
liste.append(frekanss[deger])
#print(liste)
eb=liste[0]
for i in range(len(liste)):
if(eb<liste[i]):
eb=liste[i]
for value , freks in frekanss.items():
if(eb==freks):
modu=value
return modu
In [4]:
frekanss=frekans([10,10,10,20,10,30,45,346,45])
print(frekanss)
In [3]:
mode(frekanss)
Out[3]:
In [ ]:
Yorumlar
Yorum Gönder