teslariu

template while true

Nov 12th, 2022
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # TEMPLATE
  4. """
  5. # Script que pide una edad y responde la condicion frente al voto
  6. # EJ:
  7. edades menores a 16: prohibido
  8. 16 cumplidos y menos de 18: optativo
  9. 18 cumplidos y menos de 70: obligatorio
  10. 70 cumplidos o mas: optativo
  11. """
  12. while True:
  13.    
  14.     #################################################
  15.     edad = int(input("Ingrese su edad: "))
  16.  
  17.     if 0 <= edad <= 15:
  18.         print("Voto: Prohibido")
  19.  
  20.     elif 16 <= edad <= 17 or edad >= 70:
  21.         print("Voto: Optativo")
  22.    
  23.     elif 18 <= edad <= 69:
  24.         print("Voto: Obligatorio")
  25.    
  26.     else:
  27.         print(f"Error, ingrese edad valida: {edad}")
  28.  
  29.     ################################################
  30.  
  31.     opcion = input("Presione cualquier tecla para continuar, o '-1' para salir: ")
  32.     if opcion == "-1":
  33.         print("Gracias por utilizar este programa...")
  34.         break
  35.    
Advertisement
Add Comment
Please, Sign In to add comment