Skip to content

Commit b6f8ac7

Browse files
committed
Updates chapter1.md
Auto commit by GitBook Editor
1 parent 5270311 commit b6f8ac7

File tree

1 file changed

+103
-3
lines changed

1 file changed

+103
-3
lines changed

chapter1.md

Lines changed: 103 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
---
66

7-
H4len\( \) 以一個int物件傳回資料項的長度
7+
群集資料型態
8+
9+
len\( \) 以一個int物件傳回資料項的長度
810

911
>>>len\(\(“one”,\)\)
1012

@@ -18,8 +20,6 @@ H4len\( \) 以一個int物件傳回資料項的長度
1820

1921
13
2022

21-
---
22-
2323
list型態 有個append\(\)方法,可以將一個物件附加至一個清單
2424

2525
就像這樣:
@@ -53,6 +53,106 @@ python 的 索引是從 0 開始
5353
\['zebra', 'forty nine', -897, 'arrvark', 200, 'more’\]
5454

5555
---
56+
57+
雖然a與b是不同的物件\(具有不同的身份\),但他們有相同的值,
58+
59+
所以他們是相等的。
60+
61+
>>> a = "many paths"
62+
63+
>>> b = "many paths"
64+
65+
>>> a is b
66+
67+
False
68+
69+
>>> a == b
70+
71+
True
72+
73+
隸屬運算符
74+
75+
對於序列或群集之類的資料型態,像是字串、清單和位元組,我們可以使使用 in 運算元來測試隸屬關係,使用 not in 來測試無隸屬關係:
76+
77+
>>> P = \(4,"frog",9,-33,9,2\)
78+
79+
>>> 2 in P
80+
81+
True
82+
83+
>>> phrase = "wild SWans by Jung Chang"
84+
85+
>>> "J" in phrase
86+
87+
True
88+
89+
---
90+
91+
邏輯運算符
92+
93+
短路表達式x AND y,事實上等價於條件語句:if x then y else false。短路表達式x OR y,則等價於條件語句:if x then true else y。
94+
95+
>>> five = 5
96+
97+
>>> two = 2
98+
99+
>>> zero = 0
100+
101+
>>> five and two
102+
103+
2
104+
105+
>>> two and five
106+
107+
5
108+
109+
>>> five and zero
110+
111+
0
112+
113+
>>> five or two
114+
115+
5
116+
117+
>>> two or five
118+
119+
2
120+
121+
>>> zero or five
122+
123+
5
124+
125+
>>> 5 \| 3
126+
127+
7
128+
129+
>>> 2&1
130+
131+
0
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
56156

57157

58158

0 commit comments

Comments
 (0)