Advertisement
Guest User

Untitled

a guest
May 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. import random
  2.  
  3. notas = [0] * 20
  4. alumnos = [""] * 20
  5.  
  6. for i in range(0,20):
  7. alumnos[i] = "alumno"+str(i)
  8. notas[i] = random.randint(1,10)
  9.  
  10. def menu():
  11. print("1)BUSCAR ALUMNO")
  12. print("2)MODIFICAR NOTA")
  13. print("3)REALIZAR MEDIA DE TODAS LAS NOTAS")
  14. print("4)REALIZAR MEDIA DE LAS NOTAS MENORES QUE 5")
  15. print("5)MOSTRAR EL ALUMNO QUE MEJORES NOTAS A SACADO")
  16. print("6)MOSTRAR EL ALUMNO QUE PEORES NOTAS A SACADO")
  17. print("7) SALIR")
  18. opc = int(input("Que quiere hacer: "))
  19. return opc
  20.  
  21. opc = menu()
  22.  
  23. def buscaralumno(opc):
  24. if opc == 1:
  25. nombre =input("Nombre del alumno que desea encontrar: ")
  26. pos = 0
  27. notaa = 0
  28. for i in range(0,20):
  29. if nombre == alumnos[i]:
  30. pos = i
  31. return pos
  32.  
  33. def modificarnota(opc,alumnos,notas):
  34. if opc ==2:
  35. pos = 0
  36. nombre = input("Nombre del alumno que desea modificar la nota: ")
  37. for i in range(0,20):
  38. if nombre == alumnos[i]:
  39. pos = i
  40. nota = int(input("Que nota desea ponerle al alumno: ",))
  41. if nota > 0:
  42. notas[pos] =[nota]
  43. return nota
  44.  
  45. def promedionotas(opc,notas):
  46. if opc == 3:
  47. lasuma = 0
  48. for i in range(0,20):
  49. lasuma = lasuma + notas[i]
  50. return lasuma
  51.  
  52. def notasmenores(opc,notas):
  53. if opc == 4:
  54. sumado = 0
  55. contador = 0
  56. for i in range(0,20):
  57. if notas[i] < 5:
  58. sumado = sumado + notas[i]
  59. contador = contador + 1
  60. calc = sumado / contador
  61. return calc
  62.  
  63. def mejornota(opc,notas):
  64. if opc == 5:
  65. mayor = 0
  66. pos = 0
  67. for i in range(0,20):
  68. if notas[i] > mayor:
  69. mayor = notas[i]
  70. pos = i
  71. return pos
  72.  
  73. def peornota(opc,notas6):
  74. menor = 99
  75. for i in range(0,20):
  76. if notas[i] < menor:
  77. menor = notas[i]
  78. return menor
  79.  
  80.  
  81. while opc != 7:
  82. opc = menu()
  83.  
  84. if opc == 1:
  85. posicion = buscaralumno(opc)
  86. print("La posicion del alumno es: ",alumnos[posicion])
  87. print("La nota del alumno es: ",notas[posicion])
  88.  
  89. if opc == 2:
  90. nota = modificarnota(opc,alumnos,notas)
  91. print("La nueva nota del alumno es: ",nota)
  92.  
  93. if opc == 3:
  94. sumadoo = promedionotas(opc,notas)
  95. print("El promedio de notas es: ",sumadoo/20)
  96.  
  97.  
  98. if opc == 4:
  99. calculo = notasmenores(opc,notas)
  100. print("El promedio de notas menores a 5 es: ",calculo)
  101.  
  102. if opc == 5:
  103. posicion = mejornota(opc,notas)
  104. print("La mejor nota es un :",notas[posicion])
  105.  
  106. if opc == 7:
  107. print("Fin del programa")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement