Advertisement
elizeub

Media de várias notas usando While no python

Aug 8th, 2021
1,473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #  Aula.py
  5. #  
  6. #  Copyright 2021 Elizeu Barbosa Abreu <elizeubcorreios@gmail.com>
  7. #  
  8. #  This program is free software; you can redistribute it and/or modify
  9. #  it under the terms of the GNU General Public License as published by
  10. #  the Free Software Foundation; either version 2 of the License, or
  11. #  (at your option) any later version.
  12. #  
  13. #  This program is distributed in the hope that it will be useful,
  14. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #  GNU General Public License for more details.
  17. #  
  18. #  You should have received a copy of the GNU General Public License
  19. #  along with this program; if not, write to the Free Software
  20. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. #  MA 02110-1301, USA.
  22. #  
  23. #  
  24.  
  25. soma = 0
  26. c = 1
  27. count = 0
  28. nota = 1
  29. nome = str(input('Digite o seu nome: '))
  30. print(f'{nome}, você pode digitar zero "0" quando quiser sair:')
  31. while (nota != 0) or (nota == ' '):
  32.     nota = float(input(f'{nome}, digite sua {c}ª nota: '))
  33.     soma += nota
  34.     c += 1
  35.     if (nota != 0) or (str(nota) == ' '):
  36.         count += 1
  37.     media = soma/count
  38.     if media >= 6:
  39.         status = '\033[1;94mAPROVADO\033[m'
  40.     else:
  41.         status = '\033[1;91mREPROVADO\033[m'
  42. print(f'{nome}, você digitou {count} notas, totalizando {soma} pontos e média {media}.\nVocê está {status}...')
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement