Advertisement
teslariu

ifelse

Aug 27th, 2021
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # turing funcion computable (es lo que puede resolver una màquina)
  5. # a la màquina se la llama computador
  6. # para resolver toda funcion computable se necesitan 3 op logicas
  7. # 1 condicional (if/else)y 2 bucles (for y while)
  8.  
  9. # condicional: decide entre V y F:
  10. """
  11. # script que pide la edad de una persona y responde si es mayor de edad
  12.  
  13. edad = int(input("Ingrese la edad: "))
  14. if edad >= 18:
  15.     print("Es mayor de edad")
  16.     print("Que bueno")
  17. else:
  18.     print("Aun es menor")
  19. print("Chau")
  20.  
  21. """
  22. """
  23. Script que pide la edad de una persona y devuelve su condición frente al
  24. voto
  25. si tiene menos de 16 años: voto prohibido
  26. si tiene 16 años o mas pero menos de 18 : voto optativo
  27. si tiene 18 años o mas pero menos de 70: voto obligatorio
  28. si tiene 70 años o mas: voto optativo
  29. """
  30. edad = int(input("Ingrese la edad: "))
  31.  
  32. if 0 < edad < 16:
  33.     print("Voto prohibido")
  34.  
  35. elif 16 <= edad < 18  or edad >= 70:
  36.     print("Voto optativo")
  37.  
  38. elif 18 <= edad < 70:
  39.     print("Voto obligatorio")
  40.  
  41. else:
  42.     print("Error: ¿no ha ingresado un nro negativo?")
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement