開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のII部(ビルトインオブジェクト)の9章(タプル、ファイルオブジェクト、その他)の練習問題5を解いてみる。
その他参考書籍
5.
- 0でない数値。
- 数値以外のオブジェクトについては空ではないもの。(ただしNoneはFalse)
がTrueと評価される。
対話型セッションでの入出力結果(Terminal)
$ python Python 3.3.0 (default, Sep 29 2012, 08:16:08) [GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> for x in [0,10,"python",[1,2,3,4,5],[],None,(0,),(),{},{'a':1},""]: ... print(x,":",bool(x)) ... 0 : False 10 : True python : True [1, 2, 3, 4, 5] : True [] : False None : False (0,) : True () : False {} : False {'a': 1} : True : False >>> quit() $
0 コメント:
コメントを投稿