Eiesenhower
Hectopat
Dosya işlemlerini kullanarak sınıftakilerin aldığı not ortalamasının harf notuna gelen karşılığını yapabildim ama bunları "Geçenler ve Kalanlar" adında iki yeni TXT dosyasına ayırmak istedim ama bir türlü yapamadım. Son iki "with open" bloğunda hatalar olduğunu biliyorum özellikle silmedim oradan tıkandım resmen. File 2 dosyasının çıktısı bu şekilde ama bundan AA ya da FF değerlerini alamadım bir türlü
Ahmet = AA
Ali = AA
Mehmet = AA
Serap = AA
Burak = AA
Sevim = AA
Sedat = AA
İlayda = AA
Memoş = FF
İlker = AA
Serpil = FF
Ahmet = AA
Ali = AA
Mehmet = AA
Serap = AA
Burak = AA
Sevim = AA
Sedat = AA
İlayda = AA
Memoş = FF
İlker = AA
Serpil = FF
Kod:
def not_hesapla(satir):
liste=satir.split(",")
isim=liste[0]
not1=liste[1]
not2=liste[2]
not3=liste[3]
nothesap= int(not1+not2+not3)/3
if (nothesap>= 90):
harf = "AA"
elif (nothesap >= 85):
harf = "BA"
elif (nothesap >= 80):
harf = "BB"
elif (nothesap >= 75):
harf = "CB"
elif (nothesap >= 70):
harf = "CC"
elif (nothesap >= 65):
harf = "DC"
elif (nothesap >= 60):
harf = "DD"
elif (nothesap >= 55):
harf = "FD"
else:
harf = "FF"
return isim+" = "+ str(harf) +"\n"
with open("notlar.txt","r",encoding="utf-8") as file:
liste2=[]
for i in file:
liste2.append(not_hesapla(i))
with open("notlar1.txt","w",encoding="utf-8") as file2:
for i in liste2:
file2.write(i)
file.close()
with open("notlar1.txt","r",encoding="utf -8") as file2:
liste3=[]
for i in file2:
liste3.append(i)
with open("notlar2.txt","w",encoding="utf-8") as file3:
for i in liste3:
file3.write(i)
Son düzenleme: