Python-lijsten

Introductie tot Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Python-gegevenstypen

  • float: echte getallen

  • int: gehele getallen

  • str: tekenreeks, tekst

  • bool: True, False

height = 1.73
tall = True
  • Elke variabele staat voor één waarde
Introductie tot Python

Probleem

  • Datawetenschap: heel veel gegevenspunten

  • Lengte van het hele gezin

height1 = 1.73
height2 = 1.68
height3 = 1.71
height4 = 1.89
  • Onhandig
Introductie tot Python

Python-lijst

  • [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]
  • Geef een verzameling waarden een naam

  • Bevat willekeurig type

  • Bevat verschillende typen

Introductie tot Python

Python-lijst

  • [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]]
Introductie tot Python

Lijsttype

type(fam)
list
type(fam2)
list
  • Specifieke functie

  • Specifiek gedrag

Introductie tot Python

Laten we oefenen!

Introductie tot Python

Preparing Video For Download...