teslariu

ejemplo if/elif/while

Jan 30th, 2021
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # if, while, for
  5.  
  6. """
  7. Programa que pide una edad y devuelve condicion ante el voto:
  8. Ej:
  9. menos de 16: prohibido
  10. de 16 a 18: optativo
  11. de 18 a 70: obligatorio
  12. de 70 en adelante: optativo
  13. """
  14. while True:
  15.     edad = int(input("Ingrese su edad: "))
  16.  
  17.     if edad < 16:
  18.         print("Voto prohibido")
  19.  
  20.     elif edad < 18 or edad > 70:
  21.         print("Voto optativo")
  22.  
  23.     else:
  24.         print("Voto obligatorio")
  25.        
  26.     opcion = input("Presione cualquier tecla (o 'x' para salir): ")
  27.     if opcion == "x":
  28.         print("Gracias por usar este programa...")
  29.         break
  30.  
Advertisement
Add Comment
Please, Sign In to add comment