Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Hay 3 estructuras lógicas en Python:
- # 1 condicional (if-else) (decisión)
- # 2 bucles: while (bucle indefinido) for (bucle definido) (repeticiones)
- # CONDICIONALES:
- # Script que pide una edad y responde si es mayor de edad o no
- edad = int(input("Ingrese su edad: "))
- if edad >= 18:
- print("Usted es mayor de edad")
- print("Felicitaciones")
- else:
- print("Usted es menor de edad aún")
- print("Que lástima....")
- # Script que pide ingresar un numero entero y responde si es par o impar
- # considere al cero como par
- # ayuda: considere el operador % (módulo o resto)
- numero = int(input('Ingrese un numero: '))
- if numero % 2 == 0:
- print('El numero es par')
- else:
- print('El numero es impar')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement