Advertisement
teslariu

while true

Jan 8th, 2022
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # 1 condicional (if-else) 2 bucles (while for)
  5.  
  6. # Hacer un script que pida una edad y responda su condicion frente
  7. # al voto
  8. # menos de 16: voto prohibido
  9. # 16 cumplidos y menos de 18: voto optativo
  10. # 18 cumplidos y menos de 70: obligatorio
  11. # 70 cumplidos o más: optativo
  12.  
  13. while True:
  14.  
  15. #######################################################
  16.    
  17.     edad = int(input("Por favor, ingrese su edad: "))
  18.  
  19.     if  0 < edad < 16:
  20.         print("Voto prohibido")
  21.  
  22.     elif 16 <= edad < 18 or edad >= 70:
  23.         print("Voto optativo")
  24.    
  25.     elif 18 <= edad < 70:
  26.         print("Voto obligatorio")
  27.    
  28.     else:
  29.         print("Edad incorrecta")
  30.  
  31. #######################################################
  32.        
  33.     opcion = input("Presione cualquier tecla para continuar (o '1' para salir): ")
  34.     if opcion == "1":
  35.         print("Gracias por usar este programa....")
  36.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement