Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ********************************************************
- # Programa : Ej 11 de Ciclos
- # Fecha: 22/10/19
- # Autor: Lic. Diego Krauthamer
- #
- # Supuesto: el nro ingresado debe estar entre -999 y 999
- # *********************************************************
- #Declaración de variables
- nro=1000.00
- opcion=""
- cantpos=0
- cantneg=0
- cantcero=0
- sumapos=0
- sumaneg=0
- #Cuerpo principal del programa
- while opcion != "C":
- # ************************************************
- # Muestro el menu de opciones
- # ************************************************
- print("**********************")
- print(" M E N U")
- print("**********************")
- print("A. Ingresar número")
- print("B. Informes")
- print("C. Salir")
- print("**********************")
- opcion=input()
- #Mostrar mensaje de error
- if opcion != "A" and opcion != "B" and opcion!="C":
- print("Ingrese una opción valida")
- # *************************************************
- # Determinar la opcion elegida
- # *************************************************
- if opcion=="A":
- #Incializacion de variables
- nro=1000.00
- #Solicito que ingrese el nro
- while nro < -999.00 or nro > 999.00:
- print("Ingrese un nro")
- nro=float(input())
- #Mostrar mensaje de error
- if nro < -999.00 or nro > 999.00:
- print("Error - ingrese un nro entre -999 y 999")
- #Determino si el nr es positivo
- if nro>0.00:
- #Incremento el contador de positivos
- cantpos=cantpos+1
- #Acumulo para el calculo del promedio
- sumapos=sumapos+nro
- #Determino si el nro es negativo
- if nro<0.00:
- #Incremento el contador de positivos
- cantneg=cantneg+1
- #Acumulo para el calculo del promedio
- sumaneg=sumaneg + nro
- #Determino si el nro es cero
- if nro==0.00:
- #Incremento el contador de cero
- cantcero=cantcero+1
- #Reportes
- if opcion=="B":
- #Mostrar y calcular los promedios de positivos y negativos
- print("Promedio de positivos:",float(sumapos/cantpos))
- print("Promedio de negativos:",float(sumaneg/cantneg))
- print("Cantidad de positivos: ",cantpos)
- print("Cantidad de negativos: ",cantneg)
- print("Cantidad de ceros: ",cantcero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement