Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Python saying pow only has 2 arguments

Why is python telling me "TypeError: pow expected 2 arguments, got 3" despite it working in IDLE (sometimes it tells me that in IDLE as well)? im simply doing pow(a,b,c). my program is very short and i do not change the definition of pow at any time since i need to use it for some exponentiation.

NOTE: This is the pow from __builtin__, not Math

like image 948
calccrypto Avatar asked Jul 23 '10 20:07

calccrypto


People also ask

Can pow () take 3 arguments?

The pow() method takes three parameters: number - the base value that is raised to a certain power. power - the exponent value that raises number. modulus - (optional) divides the result of number paused to a power and finds the remainder: number^power % modulus.

What does POW () mean in Python?

The pow() function returns the value of x to the power of y (xy). If a third parameter is present, it returns x to the power of y, modulus z.

What is the difference between POW and math POW in Python?

pow() have some big differences. The pow() function is comparatively faster for large set of values. On the other hand for using math. pow() the user has to first import math module.

Is Pow an inbuilt function in Python?

Power Python: pow() Method. Python includes a built-in function that can be used to calculate powers: pow(). pow() accepts three parameters: a base number, an exponent to which the base is raised, and a modulo operator.


1 Answers

Built-in pow takes two or three arguments. If you do from math import * then it is replaced by math's pow, which takes only two arguments. My recommendation is to do import math, or explicitly list functions you use in import list. Similar issue happens with open vs. os.open.

like image 192
sdcvvc Avatar answered Oct 22 '22 17:10

sdcvvc