本文实例讲述了Python中pow()和math.pow()函数用法。分享给大家供大家参考,具体如下:
1. 内置函数pow()
1
2
3
4
5
6
7
8
9
10
11
|
>>> help ( pow ) Help on built - in function pow in module __builtin__: pow (...) pow (x, y[, z]) - > number With two arguments, equivalent to x * * y. With three arguments, equivalent to (x * * y) % z, but may be more efficient (e.g. for longs). >>> >>> pow ( 3 , 2 ) # 3**2 9 >>> pow ( 3 , 2 , 4 ) # (3**2)%4 1 |
2. math.pow()
1
2
3
4
5
6
7
8
9
|
>>> import math >>> help (math. pow ) Help on built - in function pow in module math: pow (...) pow (x, y) Return x * * y (x to the power of y). >>> math. pow ( 3 , 2 ) 9.0 >>> |
希望本文所述对大家Python程序设计有所帮助。
原文链接:http://blog.csdn.net/sxingming/article/details/52119854