Python Training Course III
Python Training Course III
Lists
Tuples 發音 too-pull 或 tub-pull 都對
Dictionaries
Sets
2
Lists and Tuples
3
Lists
4
如何建立 list
Create with [ ] or list()
Value 可以不必是唯一
5
如何建立 list
Convert Other Data Types to Lists
Create list with split
6
Get an Item by Using [ offset ]
7
Lists of Lists
8
Change an Item by [ offset ], get slice of lists
9
Add an Item to the End with append()
10
Combine Lists by Using extend() or +=
11
Add an Item by Offset with insert()
12
Delete an Item by Offset with del
13
Delete an Item by Value with remove()
14
Get an Item by Offset and Delete It by Using pop()
15
Find an Item’s Offset by Value with index()
16
Test for a Value with in
17
Count Occurrences of a Value by Using count()
18
Convert to a String with join()
19
Reorder Items with sort()
20
Get Length by Using len()
21
Assign with =, Copy with copy()
22
copy a list to an independent, fresh list
23
Lists 練習題
Book P.67
Things to Do 3.1~3.9
24
Tuple
25
Create a Tuple by Using ()
26
Using tuple exchange values without temp. variable
27
Tuple 與 Lists 的比較
tuples 使用較少的記憶體空間
不會因失誤而損壞 tuple
可將 tuples 作為 dictionary 的 keys
函數的引數是以 tuples 傳遞
28
Dictionary
29
Dictionary
30
Dictionary Create with { }
31
Convert by Using dict()
32
Add or Change an Item by [ key ]
33
Key 必須是唯一
34
Combine Dictionaries with update()
35
Delete an Item by Key with del
37
Get an Item by [ key ]
38
Get All Keys by Using keys()
39
Assign with =, Copy with copy()
Dictionaries 練習題
41
Set
set 可以看成是 “有 key 無 value” 的 dictionary
42
回顧一下小學教過的集合 (sets) 概念
Create with set()
{ } 會產生一個空的 dict ,
而不是空的 set
Convert from Other Data Types with set()
Test for Value by Using in
Combinations and Operators
交集
/home/jianlong/ 影片 /Lady.Bird.mp4
Combinations and Operators
Combinations and Operators
Make Bigger Data Structures
About key of dict
Book P.68
Things to Do 3.15~3.18
52