Commits

INADA Naoki committed 45b4580

basic: Python 3 対応

Comments (0)

Files changed (1)

 
    >>> a = 3
    >>> b = a+2
-   >>> print b
+   >>> print(b)
    5
    >>> del b
    >>> b
 php と大きく違う点として、一度も代入されていない変数の値を参照しようとすると、
 例外が発生します。
 
-   >>> print abc
+   >>> print(abc)
    Traceback (most recent call last):
      File "<ipython-input-2-037277b7e5b8>", line 1, in <module>
        print abc
    >>> a = 6
    >>> b = 3
    >>> if a == b:
-   ...     print "foo"
+   ...     print("foo")
    ... elif a % b == 0:
-   ...     print "bar"
+   ...     print("bar")
    ... else:
-   ...     print "baz"
+   ...     print("baz")
    ... 
    bar
 
 
    >>> a = 1
    >>> while a < 100:
-   ...     print a
+   ...     print(a)
    ...     a *= 2
    ... 
    1
    ...     a = b
    ...     if a >= 100:
    ...         break
-   ...     print a
+   ...     print(a)
    ...     b *= 2
    ... 
    1
 
    >>> a = 1
    >>> while True:
-   ...     print a
+   ...     print(a)
    ...     a *= 2
    ...     if a >= 100:
    ...         break
 関数と組み合わせて次のように書きます。
 
    >>> for i in range(3):
-   ...     print i
+   ...     print(i)
    ... 
    0
    1