Advertisement
diegokr

Ciclos Ejercicio 11

Oct 22nd, 2019
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.32 KB | None | 0 0
  1. # ********************************************************
  2. # Programa : Ej 11 de Ciclos
  3. # Fecha: 22/10/19
  4. # Autor: Lic. Diego Krauthamer
  5. #
  6. # Supuesto: el nro ingresado debe estar entre -999 y 999
  7. # *********************************************************
  8.  
  9. #Declaración de variables
  10. nro=1000.00
  11. opcion=""
  12. cantpos=0
  13. cantneg=0
  14. cantcero=0
  15. sumapos=0
  16. sumaneg=0
  17.  
  18. #Cuerpo principal del programa
  19. while opcion != "C":
  20.  
  21.   # ************************************************
  22.   # Muestro el menu de opciones
  23.   # ************************************************
  24.   print("**********************")
  25.   print("    M E N U")
  26.   print("**********************")
  27.   print("A. Ingresar número")
  28.   print("B. Informes")
  29.   print("C. Salir")
  30.   print("**********************")
  31.   opcion=input()
  32.  
  33.   #Mostrar mensaje de error
  34.   if opcion != "A" and opcion != "B" and opcion!="C":
  35.      print("Ingrese una opción valida")
  36.  
  37.   # *************************************************
  38.   # Determinar la opcion elegida
  39.   # *************************************************
  40.   if opcion=="A":
  41.  
  42.       #Incializacion de variables
  43.       nro=1000.00
  44.  
  45.       #Solicito que ingrese el nro
  46.       while nro < -999.00 or nro > 999.00:
  47.           print("Ingrese un nro")
  48.           nro=float(input())
  49.          
  50.           #Mostrar mensaje de error
  51.           if nro < -999.00 or nro > 999.00:
  52.               print("Error - ingrese un nro entre -999 y 999")
  53.  
  54.       #Determino si el nr es positivo
  55.       if nro>0.00:
  56.         #Incremento el contador de positivos
  57.         cantpos=cantpos+1
  58.         #Acumulo para el calculo del promedio
  59.         sumapos=sumapos+nro
  60.  
  61.       #Determino si el nro es negativo
  62.       if nro<0.00:
  63.           #Incremento el contador de positivos
  64.           cantneg=cantneg+1
  65.  
  66.           #Acumulo para el calculo del promedio
  67.           sumaneg=sumaneg + nro  
  68.       #Determino si el nro es cero
  69.       if nro==0.00:
  70.           #Incremento el contador de cero
  71.           cantcero=cantcero+1
  72.  #Reportes
  73.   if opcion=="B":
  74.       #Mostrar y calcular los promedios de positivos y negativos
  75.       print("Promedio de positivos:",float(sumapos/cantpos))
  76.       print("Promedio de negativos:",float(sumaneg/cantneg))
  77.       print("Cantidad de positivos: ",cantpos)
  78.       print("Cantidad de negativos: ",cantneg)
  79.       print("Cantidad de ceros: ",cantcero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement