listas y fecha en python
DESCRIPTION
Power for the class of PythonTRANSCRIPT
![Page 1: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/1.jpg)
LISTASLISTASColecciones
![Page 2: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/2.jpg)
LISTAS
• Una LISTA es un tipo de dato de Python que permite almacenar COLECCIONES de elementos.
• Las LISTAS son:
• Mutables
• Dinámicas
![Page 3: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/3.jpg)
LISTAS
• Definición: identificador=[lista de elementos]
• Tipo de dato de los elementos:
• int, float, boolean, list, …
![Page 4: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/4.jpg)
CONSULTAS
• len(lista)
• type(lista)
![Page 5: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/5.jpg)
LISTAS• Acceso a los elementos: identificador[posición]
• En una lista encontramos:
• Elementos: lista[posición]
• Posición: 0 .. len(lista) - 1
![Page 6: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/6.jpg)
LISTAS
• Acceso a los elementos:
![Page 7: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/7.jpg)
RECORRIENDO LISTAS
• MÓDULO: UsoDeListas.py
![Page 8: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/8.jpg)
RECORRIENDO LISTAS
• Uso de sentencia for in:
![Page 9: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/9.jpg)
RECORRIENDO LISTAS
• Uso de sentencia for range:
• +
![Page 10: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/10.jpg)
RECORRIENDO LISTAS
• Determinar el mayor valor dentro de una lista:
![Page 11: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/11.jpg)
OPERACIONES LISTAS
![Page 12: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/12.jpg)
OPERACIONES LISTAS
• Agregar un elemento:
• append
• Agregar un elemento:
• extend
![Page 13: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/13.jpg)
OPERACIONES LISTAS
• Insertar un elemento:
• insert
![Page 14: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/14.jpg)
OPERACIONES LISTAS
• Eliminar un elemento: del(lista[i]), lista.remove(elem)
![Page 15: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/15.jpg)
CONSULTAS LISTAS• Determinar índice: lista.index(elem)
• Determinar existencia: elemento in lista
![Page 16: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/16.jpg)
ELEMENTOS REPETIDOS
• Veces que aparece un elemento: lista.count(elem)
![Page 17: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/17.jpg)
LISTA: ORDENAR - INVERTIR
• Ordenar: lista.sort()
• Invertir: lista.reverse()
![Page 18: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/18.jpg)
LISTAS: OPERACIONES
• +
![Page 19: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/19.jpg)
LISTAS: OPERACIONES
• *
![Page 20: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/20.jpg)
LISTAS COMO CONTADORES
• Cada uno de sus elementos, cumple la función de contador.
![Page 21: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/21.jpg)
FECHA -HORAFECHA -HORAOBTENER LA FECHA DEL SISTEMA
![Page 22: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/22.jpg)
FECHA DEL SISTEMA
• import datetime
• Diferentes formas de instanciar un objeto FECHA
![Page 23: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/23.jpg)
FECHA DEL SISTEMA
• import datetime
![Page 24: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/24.jpg)
CONVERSIONES FECHA
• import datetime
• Fecha a String: strftime(formato String)
![Page 25: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/25.jpg)
CONVERSIONES FECHA
• import datetime
• String a Fecha: strptime(String, )
![Page 26: Listas y fecha en Python](https://reader037.vdocuments.net/reader037/viewer/2022100221/557b784ed8b42aff318b4799/html5/thumbnails/26.jpg)
OTRAS FUNCIONES DE FECHA
• Ver otras funciones de fecha:
• timedelta(??)
• isoweekday()