Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. lista1 = open("studenci.txt")
  2. grupy = open("grupa.txt","w")
  3.  
  4. imie=[]
  5. nazwisko=[]
  6. grupa=[]
  7. indeksy=[]
  8.  
  9.  
  10. for line in lista1:
  11. currentline=line.split(",")
  12. imie.append(currentline[0])
  13. nazwisko.append(currentline[1])
  14. grupa.append(currentline[2])
  15.  
  16.  
  17. doc_grupa=input("Podaj grupe: ")
  18.  
  19. for i in range(0,len(imie)):
  20. if (grupa[i]==doc_grupa):
  21. indeksy.append(i)
  22.  
  23. for x in indeksy:
  24. grupy.write(imie[x])
  25. grupy.write(" ")
  26. grupy.write(nazwisko[x])
  27. grupy.write(" ")
  28. grupy.write(grupa[x])
  29. grupy.write("\n")
  30.  
  31. lista1.close()
  32. grupy.close()
  33.  
  34.  
  35.  
  36. x=[]
  37.  
  38. def avg(*arg):
  39. x=list(arg)
  40. n=len(x)
  41. if n==0:
  42. return 0
  43. else:
  44. return sum(x)/n
  45.  
  46. print(avg(2,6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement