1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Scalars:
>>> import math
>>> math.pi
3.141592653589793
>>> math.pi
3.1416
>>> math.pi
3.14
>>> -math.pi
-3.14
>>> math.pi
3.
>>> 3.
3.0
>>> 3.
3.
>>> 3.
3.01
>>> 3.
2.99
>>> .299
.3
>>> .301
.3
>>> 951.
1e3
>>> 1049.
1e3
>>> -1049.
-1e3
>>> 1e3
1e3
>>> 1e3
1000.
Lists:
>>> [3.1415, 0.097, 13.1, 7, 8.22222e5, 0.598e-2]
[3.14, 0.1, 13., 7, 8.22e5, 6.0e-3]
>>> [[0.333, 0.667], [0.999, 1.333]]
[[0.33, 0.667], [0.999, 1.333]]
>>> [[[0.101]]]
[[[0.1]]]
Doesn't barf on non-numbers:
>>> 'abc'
'abc'
>>> None
# The current implementation doesn't understand that numbers inside
# strings shouldn't be treated as numbers:
>>> '3.1416'
'3.14'
|