萌萌的生活
1.內(nèi)置函數(shù)pow()
>>> help(pow) ----查看幫助
Help on built-in function pow in module __builtin__: pow(...) pow(x, y[, z]) -> number /----有3個(gè)參數(shù),第三個(gè)是可選參數(shù)----/ 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 /----兩個(gè)參數(shù)情況----/
9
>>> pow(3,2,4)# (3**2)%4 /----三個(gè)參數(shù)的情況----/
1
對(duì)3的2次方取余
pow(x,y[,z])雖然有3個(gè)參數(shù),但第三個(gè)是可選參數(shù),表示對(duì)前面的指數(shù)取余數(shù)
正常情況下用前面兩個(gè)就好。
2.math.pow()
>>> 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
兩個(gè)參數(shù)math.pow(x,y)就很容易理解了,就是單純的x 的y次方。