Last active
April 10, 2018 21:32
-
-
Save ilkermanap/3ddc872193b5769257abfa182eeb5a18 to your computer and use it in GitHub Desktop.
Sinav sonuclari degerlendirmesi icin basit ornek, python sinif kullanimi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1:AXBadadadadaadadadaaddbbbbbdada | |
2:AAAadadadacacacacacacdadadadada | |
3:BCAadadadadadadadadadadadadadad | |
4:AXAadadadadadadadadadadadadadaA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sinif : 3A | |
----------------------------- | |
1 Ilker | |
Matematik {'dogru': 6, 'yanlis': 24, 'bos': 1} | |
Fizik {'dogru': 12, 'yanlis': 18, 'bos': 1} | |
2 Ayse | |
Matematik {'dogru': 11, 'yanlis': 20, 'bos': 0} | |
Fizik {'dogru': 14, 'yanlis': 17, 'bos': 0} | |
3 Mehmet | |
Matematik {'dogru': 0, 'yanlis': 31, 'bos': 0} | |
Fizik {'dogru': 29, 'yanlis': 2, 'bos': 0} | |
4 Sukufe | |
Matematik {'dogru': 0, 'yanlis': 30, 'bos': 1} | |
Fizik {'dogru': 30, 'yanlis': 0, 'bos': 1} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sinif: | |
def __init__(self, adi): | |
self.adi = adi | |
self.ogrenciler = {} | |
def ogrenciVarmi(self, ogrno): | |
return ogrno in self.ogrenciler | |
def ogrenciEkle(self, ogrenci): | |
self.ogrenciler[ogrenci.ogrno] = ogrenci | |
def rapor(self, notlar=False): | |
print("Sinif :", self.adi, "\n-----------------------------") | |
for k,v in self.ogrenciler.items(): | |
v.rapor(notlar=notlar) | |
def sonucEkle(self, ogrno, sinav, sonuc): | |
if ogrno in self.ogrenciler: | |
self.ogrenciler[ogrno].sonucEkle(sinav, sonuc) | |
class Ogrenci: | |
def __init__(self, ogrno, adi): | |
self.ogrno = ogrno | |
self.adi = adi | |
self.sinavlar = {} | |
def rapor(self, notlar=False): | |
print(self.ogrno, self.adi) | |
if notlar is True: | |
for k,v in self.sinavlar.items(): | |
print(" ", k, v) | |
def sonucEkle(self, sinav, sonuc): | |
self.sinavlar[sinav] = sonuc | |
class Sinav: | |
def __init__(self, adi, sinif, cevapkagidi): | |
self.adi = adi | |
self.sinif = sinif | |
# "ADCDADDAADCB" seklinde dogru cevaplar stringi | |
self.cevapkagidi = cevapkagidi.upper() | |
def degerlendir(self, ogrenci_cevap): | |
ogrenci_cevap = ogrenci_cevap.upper() | |
dogru = 0 | |
yanlis = 0 | |
bos = 0 | |
uzunluk = len(ogrenci_cevap) | |
for idx in range(uzunluk): | |
if ogrenci_cevap[idx] == "X": | |
bos +=1 | |
else: | |
if self.cevapkagidi[idx] == ogrenci_cevap[idx]: | |
dogru +=1 | |
else: | |
yanlis +=1 | |
return {"dogru":dogru, "yanlis":yanlis, "bos":bos} | |
def sonuclar(self, dosya_adi): | |
""" | |
ogrenci cevaplarinin bulundugu dosya | |
ogrno1:ACDXDACDA | |
ogrno2:CBDABXADA | |
seklinde | |
""" | |
for satir in open(dosya_adi, "r"): | |
satir = satir.strip() | |
ogrno, cevap = satir.split(":") | |
ogrno = int(ogrno) | |
if self.sinif.ogrenciVarmi(ogrno): | |
self.sinif.sonucEkle(ogrno, self.adi, self.degerlendir(cevap)) | |
if __name__ == "__main__": | |
ogrenciler = {1:"Ilker", 2:"Ayse", 3:"Mehmet", 4:"Sukufe"} | |
sinif = Sinif("3A") | |
for ogrno, adi in ogrenciler.items(): | |
sinif.ogrenciEkle(Ogrenci(ogrno, adi)) | |
s = Sinav("Fizik", sinif,"AXAadadadadadadadadadadadadadad") | |
s.sonuclar("a.txt") | |
q = Sinav("Matematik",sinif, "ddcdcdcdcdcdcdcdcdcdcdcdcdcdcdc") | |
q.sonuclar("a.txt") | |
sinif.rapor(notlar=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python 3 uyumu icin print ifadeleri duzenlendi. dict kullanirken keys() ayrica belirtmeye gerek yok. d = {} for k in d dedigimizde d icindeki anahtarlara erisiliyor. "anahtar" in d seklinde kullanim ile, d sozlugunde "anahtar" key olarak var mi kontrolu yapiliyor.