Advertisement
diegokr

Ejercicio 2

Nov 13th, 2019
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # *******************************************
  2. # Segundo Parcial Práctico - Ejercicio 2
  3. # Fecha: 5/11/19
  4. # Autor: Lic. Diego Krauthamer
  5. # Descripción: Adivinar un nro
  6. # *******************************************
  7.  
  8. #Declaración de constantes
  9. NROMAGICO=33
  10. MAXINTENTOS=3
  11.  
  12. #Declaración de variables
  13. nro=-1
  14. ciclo=1
  15.  
  16. #Cuerpo principal del programa
  17. while ciclo <=3:
  18.  
  19.     #Inicializacion de variables
  20.     nro=-1
  21.    
  22.     #Ingreso de datos y validacion
  23.     while nro <0 or nro >41:
  24.         print("Ingrese un número entre 0 y 41:")
  25.         nro=int(input())
  26.  
  27.         #Mensaje de error
  28.         if nro <0 or nro >41:
  29.             print("ERROR- Por favor Ingrese un número entre 0 y 41:")
  30.  
  31.     #Determino si adivino el nro
  32.     if nro==NROMAGICO:
  33.         print("!!!!Felicitaciones Adivino el NRO!!!!")
  34.     else:
  35.         print("No adivino, le quedan ",MAXINTENTOS-ciclo," intentos")
  36.  
  37.     #Incremento el contador
  38.     ciclo=ciclo +1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement