Advertisement
teslariu

if

Jan 21st, 2022
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # En Python, existen solo 3 estructuras lógicas:
  5. # 1 condicional (if-else)
  6. # 2 bucles (while, for)
  7.  
  8. # condicional con dos opciones:
  9. """
  10. Script que le pide la edad a una persona y responde si es mayor de edad
  11. o no
  12. """
  13. edad = int(input("Ingrese su edad: "))
  14.  
  15. if edad >= 18:
  16.     print("Usted ya es mayor de edad")
  17.     print("Felicitaciones...")
  18.  
  19. else:
  20.     print("Usted es menor de edad")
  21.     print("Mala suerte...")
  22.  
  23. print("Chau")
  24.  
  25. # condicional con más de dos opciones
  26. # Script que dice si un equipo de futbol gano, perdió o empato
  27. goles_a_favor = int(input("Ingrese la cantidad de goles anotados: "))
  28. goles_en_contra = int(input("Ingrese la cantidad de goles recibidos: "))
  29.  
  30. if goles_a_favor > goles_en_contra:
  31.     print("Ganó")
  32.    
  33. elif goles_a_favor < goles_en_contra:
  34.     print("Perdió")
  35.    
  36. else:
  37.     print("Empató")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement