Listes Python

Introduction à Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Types de données Python

  • float - nombres réels

  • int - nombres entiers

  • str - chaîne, texte

  • bool - Vrai, Faux

height = 1.73
tall = True
  • Chaque variable représente une valeur unique
Introduction à Python

Problème

  • Science des données : de nombreux points de données

  • Taille de toute la famille

height1 = 1.73
height2 = 1.68
height3 = 1.71
height4 = 1.89
  • Inconfortable
Introduction à Python

Liste 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]
  • Nommer un ensemble de valeurs

  • Contient tout type

  • Contient différents types

Introduction à Python

Liste 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]]
Introduction à Python

Type de liste

type(fam)
list
type(fam2)
list
  • Fonctionnalité spécifique

  • Comportement spécifique

Introduction à Python

Passons à la pratique !

Introduction à Python

Preparing Video For Download...