teslariu

iter

Jun 13th, 2022
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Un lenguaje es Turing Completo cuando puede evaluar cualquier función
  5. # computable
  6. #
  7. # Cualquier función computable puede ser descripta como una combinaciòn
  8. # de bucles y condicionales lògicos
  9. #
  10. # Se necesitan al menos 1 condicional, 1 bucle definido, 1 bucle indefinido
  11. #
  12. # if, for, while
  13. #
  14. """
  15. edad = int(input("Ingrese su edad: "))
  16.  
  17. if 0 < edad < 16:
  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. """    
  29. # bucle indefinido
  30. nombres = ["Juan","Hugo","Ana"]
  31.  
  32. i = 0
  33. while(i < len(nombres)):
  34.     print(nombres[i])
  35.     i += 1
  36.    
  37. # bucle definido: for <variable iteradora> in <iterable>:
  38. # TODA COLECCION ES ITERABLE
  39. for nombre in nombres:
  40.     print(nombre)
  41.    
  42. for letra in "HIOIO":
  43.     print(letra,end="  ")
  44.  
  45. print()    
  46.    
  47. for numero in range(101):
  48.     print(numero)
  49.    
  50. nombres = ["Ana","Juana","Tito"]
  51. notas = [10,8,9]
  52.  
  53. for nombre,nota zip(nombres,notas):
  54.     print(nombre,nota)
  55.  
Advertisement
Add Comment
Please, Sign In to add comment