# タプル (Tuple) ###### tags: `Python` タプルとリストはよく似ています。 「複数のオブジェクトをひとつにまとめたもの」 ということができます。 タプルは ( ) で括って記述します。 ``` python= tuple_ex = (7, "python", 100, "はい") print(tuple_ex) print(type(tuple_ex)) ``` **Results:** ``` (7, 'python', 100, 'はい') <class 'tuple'> ``` ## タプルとリストの違い * ### 変数の宣言 ``` python= # リスト list_ex = [1, 2, 3, 4, 5] #[] # タプル tuple_ex = (1, 2, 3, 4, 5) #() ``` * ### イミュータブル(変更ができない) リストには要素を追加したり、要素を消したりすることもできますが、タプルではできません。 ```python= tuple_ex = (1, 2, 3, 4, 5) tuple_ex[0] = 5 print(tuple_ex) ``` **Results:** ![](https://i.imgur.com/QK6RtPC.png) * ### タプルは実行速度が少し早い