Liste Python

Introducere în Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Tipuri de date Python

  • float - numere reale

  • int - numere întregi

  • str - șir de caractere, text

  • bool - True, False

height = 1.73
tall = True
  • Fiecare variabilă reprezintă o singură valoare
Introducere în Python

Problemă

  • Știința datelor: multe puncte de date

  • Înălțimea întregii familii

height1 = 1.73
height2 = 1.68
height3 = 1.71
height4 = 1.89
  • Incomod
Introducere în Python

Listă 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]
  • Denumește o colecție de valori

  • Poate conține orice tip

  • Poate conține tipuri diferite

Introducere în Python

Listă 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]]
Introducere în Python

Tipul list

type(fam)
list
type(fam2)
list
  • Funcționalitate specifică

  • Comportament specific

Introducere în Python

Să exersăm!

Introducere în Python

Preparing Video For Download...