Python リスト

Python 入門

Hugo Bowne-Anderson

Data Scientist at DataCamp

Pythonデータ型

  • float - 実数

  • int - 整数

  • str - 文字列、テキスト

  • bool - True(真)、False(偽)

height = 1.73
tall = True
  • 各変数は1つの値を表す
Python 入門

問題

  • データサイエンス:大量のデータポイントを扱う

  • 家族全員の身長

height1 = 1.73
height2 = 1.68
height3 = 1.71
height4 = 1.89
  • 不便
Python 入門

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]
  • 複数の値に1つの名前を付けられる

  • どの型の値でも入れられる

  • 異なる型の値を混在させられる

Python 入門

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]]
Python 入門

リスト型

type(fam)
list
type(fam2)
list
  • 型ごとの機能

  • 型ごとの動作

Python 入門

練習しましょう!

Python 入門

Preparing Video For Download...