Advertisement
Guest User

ex2

a guest
May 23rd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. archivo = open("dataestudiantes1.csv","r")
  2. counter=0
  3.  
  4. comparador=-1
  5. comparador2=8
  6. for linea in archivo:
  7.    
  8.     if counter==0:
  9.         pass
  10.     else:
  11.         #print linea
  12.         lista=linea.strip().split(",")
  13.         ID= lista[0].replace('"',"")
  14.         RUT_ID= lista[1].replace('"',"")
  15.         nombre_est= lista[2].replace('"',"")
  16.         #print lista[3].replace('"',"").replace(" ","")
  17.         nota1= float(lista[3].replace('"',"").replace(" ",""))
  18.         nota2= float(lista[4].replace('"',"").replace(" ",""))
  19.         nota3= float(lista[5].replace('"',"").replace(" ",""))
  20.         nota4= float(lista[6].replace('"',"").replace(" ",""))
  21.         nota5= float(lista[7].replace('"',"").replace(" ",""))
  22.         promedio=round(((nota1+nota2+nota3+nota4+nota5)/5),1)
  23.         print nombre_est, promedio
  24.        
  25.         if promedio > comparador:
  26.             comparador=promedio
  27.             mejoralumno=nombre_est
  28.        
  29.         if promedio <= comparador2:
  30.             comparador2=promedio
  31.             peoralumno=nombre_est
  32.     counter+=1
  33. print "El mejor alumno es: ", mejoralumno, "y su nota es: ", comparador
  34. print "El peor alumno es: ", peoralumno, "y su nota es: ", comparador2
  35.        
  36. #print "el promedio es", nota1+nota2
  37. archivo.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement