Skip to content

Commit 6904346

Browse files
committed
Updates chapter1.md
Auto commit by GitBook Editor
1 parent 89759ec commit 6904346

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

chapter1.md

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,24 @@ if 陳述句
136136

137137
與其他語言不同的是Python使用縮排來表示它的區塊結構。
138138

139-
if lines <1000:
140-
141-
```
142-
print\("small"\)
143-
```
144-
145-
elif lines <10000:
146-
147-
```
148-
print\("medium"\)
139+
```py
140+
if lines <1000:
141+
print\("small"\)
142+
elif lines <10000:
143+
print\("medium"\)
144+
else:
145+
print("large")
149146
```
150147

151-
else:
152148

153-
print\("large"\)
154149

155150
---
156151

157152
for...in陳述句
158153

159-
for country in \["Denmark","Finland","Norway","Sweden"\]:
160-
161154
```py
162-
print\(country\)
155+
>>>for country in ["Denmark","Finland","Norway","Sweden"]:
156+
print\(country\)
163157
```
164158

165159
Denmark
@@ -170,9 +164,9 @@ Norway
170164

171165
Sweden
172166

173-
&gt;&gt;&gt; for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
174-
175-
```
167+
```py
168+
>>> for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
169+
176170
if letter in "AEIOU":
177171

178172
print\(letter,"is vowel"\)
@@ -238,20 +232,14 @@ Z is a consonant
238232

239233
函式的建立與呼叫
240234

241-
&gt;&gt;&gt; def get\_int\(msg\):
242-
243235
```
244-
while True:
245-
246-
try:
247-
248-
i=int\(input\(msg\)\)
249-
236+
>>> def get_int(msg):
237+
while True:
238+
try:
239+
i=int\(input\(msg\)\)
250240
return i
251-
252-
except ValueError as err:
253-
254-
print\(err\)
241+
except ValueError as err:
242+
print\(err\)
255243
```
256244

257245
&gt;&gt;&gt; get\_int\(3\)

0 commit comments

Comments
 (0)