2014年7月25日金曜日

開発環境

Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 5(Making Choices)、5.6(Exercises) 1.を解いてみる。

5.6(Exercises) 1.

入出力結果(Terminal, IPython)

$ ipython
Python 3.4.1 (default, May 21 2014, 01:39:38) 
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: True and not False # True
Out[1]: True

In [2]: True and not false # Error
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-77ba11cef650> in <module>()
----> 1 True and not false # Error

NameError: name 'false' is not defined

In [3]: True or True and False # True
Out[3]: True

In [4]: not True or not False # True
Out[4]: True

In [5]: True and not 0 # True
Out[5]: True

In [6]: 52 < 52.3 # True
Out[6]: True

In [7]: 1 + 52 < 52.3 # False
Out[7]: False

In [8]: 4 != 4.0 # False
Out[8]: False

In [9]: quit()
$

0 コメント:

コメントを投稿