teslariu

notas while True

May 13th, 2023
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Hacer un script que pida el ingreso de notas de un alumno. La carga debe terminar cuando se ingrese la nota igual a -1. En ese momento, deben mostrar la cantidad de notas, la nota máxima, la nota mínima y el promedio con dos cifras de exactitud
  6. """
  7. notas = []
  8. while True:
  9.     nota = input("Ingrese una nota: ")
  10.     if nota.isdigit() and 0 < int(nota) <= 10:
  11.         notas.append(int(nota))
  12.    
  13.     elif nota == "-1":
  14.         break
  15.        
  16.     else:
  17.         print("Error en el ingreso de la nota")
  18.        
  19. print(f"Cantidad de notas: {len(notas)}")
  20. print(f"Nota máxima: {max(notas)}")        
  21. print(f"Nota mínima: {min(notas)}")
  22. print(f"Promedio de notas: {sum(notas)/len(notas):.2f}")
Advertisement
Add Comment
Please, Sign In to add comment