Skip to content

Instantly share code, notes, and snippets.

@mertcangokgoz
Created January 24, 2019 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mertcangokgoz/132c48ff1337fd90834fd4fe53b82e41 to your computer and use it in GitHub Desktop.
Save mertcangokgoz/132c48ff1337fd90834fd4fe53b82e41 to your computer and use it in GitHub Desktop.
import sys
def mod(sayilar):
try:
en_yuksek = 0
for s in sayilar:
if sayilar.count(s) > sayilar.count(en_yuksek):
en_yuksek = s
return en_yuksek
except Exception as e:
print("\n[ mod(sayilar) Hata ]\n\t Hata Mesajı:\t ", e, "\n")
sys.exit(1)
def medyan(sayilar):
try:
sayilar.sort()
uzunluk = len(sayilar)
aradakisayi = int(uzunluk / 2)
if uzunluk % 2 == 0:
return str(sayilar[aradakisayi - 1]) + " " + str(sayilar[aradakisayi])
else:
return sayilar[aradakisayi]
except Exception as e:
print("\n[ medyan(sayilar) Hata ]\n\t Hata Mesajı:\t ", e, "\n")
sys.exit(1)
def ortanca(sayilar):
try:
stoplam = 0
for s in sayilar:
stoplam = stoplam + s
return stoplam / len(sayilar)
except Exception as e:
print("\n[ ortanca(sayilar) Hata ]\n\t Hata Mesajı:\t ", e, "\n")
sys.exit(1)
def about():
print("--- ")
print("Temel İstatistiki işlemler için geliştirilmiş algoritmaları içerir.")
print("--- ")
print("")
def islemler():
girdiler = input("İşlem yapılacak sayıları teker teker giriniz: ")
sayilar = sorted(map(int, girdiler.split()))
print("Ortanca: ", ortanca(sayilar))
print("Medyan: ", medyan(sayilar))
print("Mod: ", mod(sayilar))
about()
islemler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment