Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Escribir un programa que le pida al usuario que ingrese numeros naturales
- hasta que el usuario ingrese -1. Al final, el programa debe imprimir la
- cantidad de nros, la suma total, el mayor y el promedio.
- NOTA: use lo que crea necesario
- """
- numeros = []
- suma = 0
- mayor = 0
- while True:
- numero = int(input("Ingrese un nro natural (-1 para salir): "))
- if numero == -1:
- break
- elif numero <= 0:
- print("Debe ingresar un nro natural")
- else:
- numeros.append(numero)
- suma = suma + numero
- if numero > mayor:
- mayor = numero
- print(f"Promedio: {suma / len(numeros)}, suma: {suma}, mayor: {mayor}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement