Advertisement
teslariu

while True

Aug 25th, 2022
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. # break: interrumpe la ejecuciòn de un bucle/condicional
  5. # continue: saltea el resto de las instrucciones dentro de un
  6. # bucle/condicional
  7.  
  8. i = 0
  9.  
  10. while i < 10:
  11.    print(i)
  12.    continue
  13.    print("JAJA")
  14.    break
  15.  
  16. print("Chau")
  17.  
  18. """
  19.  
  20.  
  21. #
  22. # Script que pide el ingreso de numeros enteros positivos y los almacena
  23. # en una lista. El ingreso de datos debe finalizar cuando se ingresa
  24. # un cero o un nro negativo. Luego, se debe imprimir el promedio, el
  25. # maximo y el mínimo
  26.  
  27. lista = []
  28.  
  29. while True:
  30.     numero = int(input("Ingrese número entero positivo: "))
  31.     if numero <= 0:
  32.         break
  33.     lista.append(numero)
  34.  
  35. print(f"El  promedio es: {sum(lista)/len(lista):.2f}")
  36. print(f"El  mínimo es: {min(lista)}")
  37. print(f"El  máximo es: {max(lista)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement