teslariu

condicional de voto

Apr 20th, 2023
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """
  5. Script que pide una edad y responde con su condicion frente al voto
  6.    si tiene menos de 16 años: voto prohibido
  7.    si tiene 16 cumplidos y menos de 18: voto optativo
  8.    18 cumplidos y menos de 70: voto obligatorio
  9.    70 o mas: voto optativo
  10. EJ:
  11. >>> Ingrese su edad: 17
  12. >>> Voto optativo
  13. """
  14. edad = int(input("Ingrese su edad: "))
  15.  
  16. # ahora hay que escribir el condicional
  17. if 0 < edad < 16:               # ojo, no puede haber edad negativa
  18.     print("Voto prohibido")
  19.  
  20. elif 16 <= edad < 18 or edad >= 70:
  21.     print("Voto optativo")
  22.    
  23. elif 18 <= edad < 70:
  24.     print("Voto obligatorio")
  25.    
  26. else:
  27.     print("Error en el ingreso de la edad")
  28.  
Add Comment
Please, Sign In to add comment