Python:模块与数学类函数(Math)
代码:
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 |
[root@mysql-me ~]# python Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> 2**3 8 >>> >>> pow(2,3) 8 >>> >>> abs(-293) 293 >>> abs(1/2) 0 >>> abs(1/2.0) 0.5 >>> >>> round(1/2) 0.0 >>> >>> round(1/2.0) 1.0 >>> >>> import math >>> >>> math.floor(1/2.0) 0.0 >>> math.floor(34.3) 34.0 >>> math.floor(34.5) 34.0 >>> >>> >>> math.ceil(34.4) 35.0 >>> math.ceil(34.5) 35.0 >>> >>> >>> ce=math.ceil >>> ce(34.4) 35.0 >>> ce(34.5) 35.0 >>> >>> exit() [root@mysql-me ~]# |
——————————————————
Done。[……]