Views
解答例7
-
>>> 1 + 2 * 3 7 >>> ( 1 + 2 ) * 3 9 >>> 10 / 0 Traceback (most recent call last): File "
", line 1, in ? ZeroDivisionError: integer division or modulo by zero >>> 1. + 2 * 3 7.0 >>> ( 1. + 2 ) * 3 9.0 >>> 10 / 0. Traceback (most recent call last): File " ", line 1, in ? ZeroDivisionError: float division >>> - ゼロで割ったときのエラーは整数と浮動少数で微妙に違うことにも注意
-
>>> from math import * >>> sin(1e-6)/1e-6 0.99999999999983336 >>> sin(1e-7)/1e-7 0.99999999999999833 >>> sin(1e-8)/1e-8 1.0 >>>
-
>>> 1e307 9.9999999999999999e+306 >>> 1e308 1e+308 >>> 1e309 inf >>> 10**10000 100000000000000... ... 0L >>>
- ちなみに
>>> 1e-323 9.8813129168249309e-324 >>> 1e-324 0.0
- ちなみに
-
>>> (1 + 2j)/(3 + 4j) (0.44+0.080000000000000002j) >>> x = 3**2 + 4**2 >>> (1*3+2*4)/x 0 >>> (1.*3+2*4)/x 0.44 >>> (2.*3-1.*4)/x 0.080000000000000002 >>>