制御文について (for, if)

項番を数えながらの for

>>> for num, enum in enumerate(['a','b','c']):
	print (str(num) + ':' + enum)

0:a
1:b
2:c

論理演算子

3項演算子

0 より小さかったら 0、それ以外はそのまま

>>> x=10
>>> 0 if x < 0 else x
10
>>> x=-10
>>> 0 if x < 0 else x
0

while

continue, break, else

やることなかったら pass

>>> if False :
            pass
        else :
	     文は ('else')
else
>>>
 
>>> if True :
            pass
        else :
	     print ('else')
>>>

switch はなし


Python


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2012-10-10 (水) 01:45:48 (4216d)
Short-URL: https://at-sushi.com:443/pukiwiki/index.php?cmd=s&k=bcd346a3f2
ISBN10
ISBN13
9784061426061