Listas Python

Introducción a Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Tipos de datos en Python

  • float - números reales

  • int - números enteros

  • str - cadena, texto

  • bool - Verdadero, Falso

height = 1.73
tall = True
  • Cada variable representa un valor único.
Introducción a Python

Problema

  • Ciencia de datos: muchos puntos de datos

  • Altura de toda la familia

height1 = 1.73
height2 = 1.68
height3 = 1.71
height4 = 1.89
  • Inconveniente
Introducción a Python

Listas Python

  • [a, b, c]
[1.73, 1.68, 1.71, 1.89]
[1.73, 1.68, 1.71, 1.89]
fam = [1.73, 1.68, 1.71, 1.89]
fam
[1.73, 1.68, 1.71, 1.89]
  • Nombra una colección de valores.

  • Contiene cualquier tipo

  • Contienen diferentes tipos

Introducción a Python

Listas Python

  • [a, b, c]
fam = ["liz", 1.73, "emma", 1.68, "mom", 1.71, "dad", 1.89]

fam
['liz', 1.73, 'emma', 1.68, 'mom', 1.71, 'dad', 1.89]
fam2 = [["liz", 1.73],
        ["emma", 1.68],
        ["mom", 1.71],
        ["dad", 1.89]]

fam2
[['liz', 1.73], ['emma', 1.68], ['mom', 1.71], ['dad', 1.89]]
Introducción a Python

Tipo de lista

type(fam)
list
type(fam2)
list
  • Funcionalidad específica

  • Comportamiento específico

Introducción a Python

¡Vamos a practicar!

Introducción a Python

Preparing Video For Download...