【5-1】
▲文字列の結合
-------------------
>>> str1 = 'Hello World'
>>> str2 = '!'
>>> str3 = str1 + str2
>>> print(str3)
Hello World!
-------------------


▲文字列と数字の結合
-------------------
>>> str1 = 'Hello World'
>>> num1 = 2021
>>> str1 = str1 + str(num1)
>>> print(str1)
Hello World2021
-------------------


▲3重引用符の使い方
-------------------
>>> a = '''文字列''', """文字列"""
>>> type(a)
<class 'tuple'>
>>> print(a)
('文字列', '文字列')
-------------------


【5-2】
▲リストの作り方
-------------------
>>> a = [1,2,3]
>>> print(a)
[1, 2, 3]
>>> type(a)
<type 'list'>
-------------------


▲リストの中から一部を取得
-------------------
>>> print([1,2,3][0])
1
>>> print([1,2,3][1])
2
>>> print([1,2,3][2])
3
-------------------


▲リストが格納されている変数をスライス
-------------------
>>> a = [1,2,3]
>>> print(a[0])
1
>>> print(a[1])
2
>>> print(a[2])
3
-------------------


▲リストの一部を範囲指定してスライス
-------------------
>>> print(a[0:2])
[1, 2]
>>> print(a[0:3])
[1, 2, 3]
>>> print(a[0:7])
[1, 2, 3]
-------------------


▲リストの前半または後半だけをスライス
-------------------
>>> print(a[1:])
[2, 3]
>>> print(a[:2])
[1, 2]
>>> print(a[:])
[1, 2, 3]
-------------------


▲リストのスライス方法のまとめ
-------------------
>>> list1 = [1, 2, 3, 4, 5, 6, 7]
>>> print(list1)
[1, 2, 3, 4, 5, 6, 7]
>>> print(list1[1])
2
>>> print(list1[1:4])
[2, 3, 4]
-------------------


▲リスト同士の演算
-------------------
>>> list1 = [1, 2, 3]
>>> list2 = [4, 5, 6]
>>> list3 = list1 + list2
>>> print(list3)
[1, 2, 3, 4, 5, 6]
-------------------


▲リストの結合
-------------------
>>> list1 = ['apple', 'orange', 'lemon']
>>> list2 = [1, 2, 3]
>>> print(list1 + list2)
['apple', 'orange', 'lemon', 1, 2, 3]
-------------------


▲多重になったリスト
-------------------
>>> list1 = ['apple', 'orange', 'lemon']
>>> list2 = ['strawberry', 'kiwi']
>>> list1.append(list2)
>>> print(list1)
['apple', 'orange', 'lemon', ['strawberry', 'kiwi']]
-------------------


▲リストへオブジェクトを追加
-------------------
>>> list1 = ['apple', 'orange', 'lemon']
>>> test1 = 'banana'
>>> list1.append(test1)
>>> print(list1)
['apple', 'orange', 'lemon', 'banana']
-------------------


▲リストの任意の位置へオブジェクトを追加
-------------------
>>> print(list1)
['apple', 'orange', 'lemon', 'banana']
>>> list1.insert(0, text1)
>>> print(list1)
['banana', 'apple', 'orange', 'lemon', 'banana']
-------------------


▲リストの最後に別のリストを追加
-------------------
>>> list1 = ['apple', 'orange', 'lemon']
>>> list2 = ['strawberry', 'kiwi']
>>> list1.extend(list2)
>>> print(list1)
['apple', 'orange', 'lemon', 'strawberry', 'kiwi']
-------------------


▲リストからオブジェクトを削除する
-------------------
>>> print(list1)
['apple', 'orange', 'lemon', 'strawberry', 'kiwi']
>>> list1.pop(3)
'strawberry'
>>> print(list1)
['apple', 'orange', 'lemon', 'kiwi']
-------------------


▲リストのオブジェクトを指定して削除
-------------------
>>> print(list1)
['apple', 'strawberry', 'orange']
>>> list1.remove('orange')
>>> print(list1)
['apple', 'strawberry']
-------------------


▲リスト同士の比較
-------------------
>>> list1 = [1, 2, 3]
>>> list2 = [3, 1, 2]
>>> print(list1 == list2)
False
>>> print(set(list1) == set(list2))
True
-------------------


【5-3】
▲タプルの初期化
-------------------
>>> tuple1 = ()
>>> type(tuple1)
<class 'tuple'>
-------------------


▲オブジェクトの入ったタプルを作る
-------------------
>>> tuple1 = 1, 2, 3
>>> type(tuple1)
<class 'tuple'>
-------------------


▲要素の表示
-------------------
>>> tuple1 = (1, 2, 3, 'A', 'B', 'C')
>>> print(tuple1[4])
B
>>> print(tuple1[1:4])
(2, 3, 'A')
-------------------


▲多重になったタプル
-------------------
>>> tuple1 = 1, 2, (3, 4)
>>> type(tuple1)
<class 'tuple'>
>>> print(tuple1)
(1, 2, (3, 4))
-------------------


【5-4】
▲空の辞書を作る
-------------------
>>> dict1 = {}
>>> print(dict1)
{}
-------------------


▲辞書にキーと値を設定
-------------------
>>> dict1 = {
    1: 'apple', 2: 'orange', 3: 'lemon',
	4: 'banana', 5: 'pinapple', 6: 'grape',
	7: 'peach'
    }
>>> print(dict1)
{1: 'apple', 2: 'orange', 3: 'lemon', 4: 'banana', 5: 'pinapple', 6: 'grape', 7: 'peach'}
-------------------


▲辞書のキーだけを表示
-------------------
>>> print(dict1.keys())
dict_keys([1, 2, 3, 4, 5, 6, 7])
>>> print(len(dict1.keys()))
7
-------------------


▲辞書の値だけを表示
-------------------
>>> print(dict1.values())
dict_values(['apple', 'orange', 'lemon', 'banana', 'pinapple', 'grape', 'peach'])
-------------------


▲キーと値の組を表示
-------------------
>>> print(dict1.items())
dict_items([(1, 'apple'), (2, 'orange'), (3, 'lemon'), (4, 'banana'), (5, 'pinapple'), (6, 'grape'), (7, 'peach')])
>>> pairs = [(v, k) for (k, v) in dict1.items()]
>>> type(pairs)
<class 'list'>
>>> print(pairs)
[('apple', 1), ('orange', 2), ('lemon', 3), ('banana', 4), ('pinapple', 5), ('grape', 6), ('peach', 7)]
-------------------


▲値の削除
-------------------
>>> a, b = dict1.popitem()
>>> print(a)
8
>>> print(b)
banana
>>> print(dict1.items())
dict_items([(1, 'apple'), (2, 'orange'), (3, 'lemon'), (4, 'banana'), (5, 'pinapple'), (6, 'grape')])
-------------------


▲キーで値を参照する
-------------------
>>> print(dict1[2])
orange
-------------------


▲値を追加する
-------------------
>>> dict1[8] = 'banana'
>>> print(dict1.items())
dict_items([(1, 'apple'), (2, 'orange'), (3, 'lemon'), (4, 'banana'), (5, 'pinapple'), (6, 'grape'), (8, 'banana')])
-------------------


▲値を更新する
-------------------
>>> dict1.update({1: 'pinapple'})
>>> print(dict1.items())
dict_items([(1, 'pinapple'), (2, 'orange'), (3, 'lemon'), (4, 'banana'), (5, 'pinapple'), (6, 'grape'), (8, 'banana')])
-------------------


▲特定の値を削除する（pop）
-------------------
>>> dict1.pop(3)
>>> print(dict1.items())
dict_items([(1, 'pinapple'), (2, 'orange'), (4, 'banana'), (5, 'pinapple'), (6, 'grape'), (8, 'banana')])
-------------------


▲特定の値を削除する（del）
-------------------
>>> del dict1[2]
>>> print(dict1.items())
dict_items([(1, 'pinapple'), (4, 'banana'), (5, 'pinapple'), (6, 'grape'), (8, 'banana')])
-------------------


▲全てのキーと値を削除する
-------------------
>>> dict1.clear()
>>> print(dict1.items())
dict_items([])
-------------------