0

pow() function

What does the third argumeny of pow() function do? And is that function is somehow related to math.pow() ??

15th Jun 2020, 3:50 PM
Python piper
Python piper - avatar
2 Réponses
+ 5
As you can see by using: help(pow) the third argument is the modulo: pow(x, y, z) == x**y % z So, pow(4, 5, 6) equals 4**5 % 6, so 1024 % 6, which is 4 (1024/6=170R4). AFAIR, math.pow only accepts the first two arguments. Plus, it always returns a float, even if the arguments are int.
15th Jun 2020, 3:51 PM
M Tamim
M Tamim - avatar
0
M Tamim thanks again.
15th Jun 2020, 3:53 PM
Python piper
Python piper - avatar