Liste in Python

Introduzione a Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Tipi di dati Python

  • float - numeri reali

  • int - numeri interi

  • str - stringa, testo

  • bool - Vero, Falso

height = 1.73
tall = True
  • Ogni variabile rappresenta un singolo valore.
Introduzione a Python

Problema

  • Scienza dei dati: un sacco di dati

  • Altezza di tutta la famiglia

height1 = 1.73
height2 = 1.68
height3 = 1.71
height4 = 1.89
  • Scomodo
Introduzione a Python

Elenco 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]
  • Dai un nome a un insieme di valori

  • Contenere qualsiasi tipo

  • Contengono diversi tipi

Introduzione a Python

Elenco 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]]
Introduzione a Python

Tipo di elenco

type(fam)
list
type(fam2)
list
  • Funzionalità specifica

  • Comportamento specifico

Introduzione a Python

Passiamo alla pratica!

Introduzione a Python

Preparing Video For Download...