File tree Expand file tree Collapse file tree 1 file changed +18
-30
lines changed
Expand file tree Collapse file tree 1 file changed +18
-30
lines changed Original file line number Diff line number Diff 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
157152for...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
165159Denmark
@@ -170,9 +164,9 @@ Norway
170164
171165Sweden
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- > ;> ;> ; 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> ;> ;> ; get\_ int\( 3\)
You can’t perform that action at this time.
0 commit comments