teslariu

forr

Sep 3rd, 2021 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # TODA COLECCION ES ITERABLE (lista, cadena, diccionario...)
  5.  
  6. nombres = ["juan", "osvaldo", "ana", "karen", "luisa"]
  7. frase = "Hola a todos"
  8.  
  9. """
  10. Ejemplos de range
  11. range(valor inicial, tope, salto)
  12.  
  13. 1. range(2,14,3) -> [2,5,8,11]
  14. 2. range(15,-16, -4) -> [15,11,7,3,-1,-5,-9,-13]
  15. 3. range(10) -> [0,1,2,3,4,5,6,7,8,9] valores x defecto: inicio=0, salto=1
  16. 4. range(4,10) -> [4,5,6,7,8,9] valor x defecto: salto=1
  17.  
  18. """
  19.  
  20.  
  21. for nombre in nombres: # for <iterador> in <iterable>:
  22. print(nombre)
  23.  
  24. for caracter in frase:
  25. print(caracter)
  26.  
  27. for numero in range(100,20,-20): # range(valor inicial, valor final, salto)
  28. print(numero)
  29.  
Add Comment
Please, Sign In to add comment