Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. def registrar(x, y):
  2. while x == 0:
  3. print('\nRegistrar um aluno = 0')
  4. print('Cancelar = 1')
  5. y = int(input('\nEscolha uma opção acima: '))
  6. if y == 0:
  7. while y == 0:
  8. nome = input('\nInforme o nome: ')
  9. nota = float(input('Informe a nota: '))
  10. matricula = int(input('Informe o número de matricula: '))
  11. if matricula < 0:
  12. print('\nO número de matricula não pode ser negativo!')
  13. y = 0
  14. else:
  15. listaalunos.append(nome)
  16. listanotas.append(nota)
  17. listamatriculas.append(matricula)
  18. print('\nAluno Registrado!')
  19. y = 1
  20. elif y == 1:
  21. x = 1
  22. else:
  23. print('\nEscolha uma opção válida.')
  24.  
  25. def media():
  26. soma = 0
  27. tamanho = 0
  28. for i in listanotas:
  29. soma = soma + i
  30. tamanho = tamanho + 1
  31. media = soma / tamanho
  32. return media
  33.  
  34. if __name__ == '__main__':
  35. listaalunos = []
  36. listanotas = []
  37. listamatriculas = []
  38. x = 0
  39. y = 0
  40.  
  41. registrar(x,y)
  42.  
  43. print('A média é {}'.format(media()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement