Advertisement
wrichaard

notas2

Apr 23rd, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.14 KB | None | 0 0
  1. '''
  2. Ler um array de 30 alunos e preencher com 3 notas e faltas
  3. '''
  4.  
  5. from os import system, name
  6. def clear():
  7.     # for windows
  8.     if name == 'nt':
  9.         _ = system('cls')
  10.  
  11.         # for mac and linux(here, os.name is 'posix')
  12.     else:
  13.         _ = system('clear')
  14.  
  15. #Cria a matriz
  16. qtdAlunos = 1
  17.  
  18.  
  19.  
  20. alunos = []
  21. for j in range(qtdAlunos):
  22.     alunos.append([0]*8)
  23.  
  24. i = 0
  25. x = 0
  26. menu = "inicio"
  27. existe = -1
  28. media = 0.0
  29. p = 0
  30. us = 0
  31.  
  32. while i < qtdAlunos:
  33.     x=0
  34.     while x <= 6:#colcoar quantidade de propriedades
  35.         print("alunos["+str(i)+"]["+str(x)+"]")
  36.         if x == 0:
  37.             alunos[i][x] = input("Digite o nome: ").upper()
  38.         elif x <  4:
  39.             alunos[i][x] = input("Digite a nota"+str(x)+" para o aluno "+str(alunos[i][0])+": ")
  40.         elif x == 4:
  41.             alunos[i][x] = input("Digite a substitutiva para o aluno "+str(alunos[i][0])+": ")
  42.         elif x == 5:
  43.             alunos[i][x] = input("Digite final para o aluno "+str(alunos[i][0])+": ")
  44.         else:
  45.             alunos[i][x] = input("Digite as faltas para o aluno "+str(alunos[i][0])+ ": ")
  46.         x = x + 1
  47.     i = i + 1
  48.  
  49. while menu.strip() != str(0):
  50.     clear()
  51.     print("\nPara imprimir o boletim, digite o nome do aluno")
  52.     print("Para ver o nome de todos os alunos digite LISTAR")
  53.     print("Para sair digite 0")
  54.  
  55.     menu = input("\nDigite a opção desejada").upper()
  56.  
  57.     if menu.strip() == "LISTAR":
  58.         i=0
  59.         while i < qtdAlunos:
  60.             print("\n"+str(alunos[i][0]))
  61.             i = i + 1
  62.     elif menu.strip() == str(0):
  63.         break
  64.     else:
  65.         print("\nPESQUISANDO...  :: "+str(menu))
  66.         x = 0
  67.         existe = -1
  68.         while x <= qtdAlunos:
  69.             if alunos[x][0] == menu.upper():
  70.                 existe = x;
  71.                 break
  72.             x = x + 1
  73.         if existe >= 0:
  74.             #verifica se alguma nota é menor que a substitutiva
  75.  
  76.             if alunos[existe][1] < alunos[existe][2]:
  77.                 if alunos[exist][1] < alunos[existe][3]:
  78.                     p = 1
  79.                 else:
  80.                     p = 3
  81.             elif alunos[existe][2] < alunos[existe][3]:
  82.                 if alunos[existe][2] < alunos[existe][1]:
  83.                     p = 2
  84.                 else:
  85.                     p = 1
  86.             else:
  87.                 p = 3
  88.  
  89.  
  90.             if alunos[existe][4] > alunos[existe][p]:
  91.                 us = 1
  92.  
  93.             if us == 0:
  94.                 media = (float(alunos[existe][1])+float(alunos[existe][2])+float(alunos[existe][3]))/3
  95.             else:
  96.                 if p == 1:
  97.                     media = (float(alunos[existe][4])+float(alunos[existe][2])+float(alunos[existe][3]))/3
  98.                 elif p == 2:
  99.                     media = (float(alunos[existe][1]) + float(alunos[existe][4]) + float(alunos[existe][3])) / 3
  100.                 else:
  101.                     media = (float(alunos[existe][1])+float(alunos[existe][2])+float(alunos[existe][4]))/3
  102.  
  103.             print("+-------------------------------------------------------------------------+")
  104.             print("|                          BOLETIM                                        |")
  105.             print("+-------------------------------------------------------------------------+")
  106.             print("| Aluno: "+str(alunos[existe][0]).ljust(65)+"|")
  107.             print("+-------------------------------------------------------------------------+")
  108.             print("| Nota01    | Nota02     | Nota 03   | Substitutiva | Final      | Media  |")
  109.             print("| "+str(alunos[existe][1]).rjust(9)+" | "+str(alunos[existe][2]).rjust(10)+" | "+str(alunos[existe][3]).rjust(9)+" | "+str(alunos[existe][4]).rjust(12)+" | "+str(alunos[existe][5]).rjust(10)+ " | "+str(float("{0:.2f}".format(media))).rjust(6)+" |")
  110.             print("+-------------------------------------------------------------------------+")
  111.             print("| Faltas: "+str(alunos[existe][6]).ljust(63)+" |")
  112.             print("+-------------------------------------------------------------------------+")
  113.  
  114.         else:
  115.             print("\nNão encontrado")
  116.             input("\nAperte enter para continuar")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement