Fix Python – Should I use scipy.pi, numpy.pi, or math.pi?

Question

Asked By – Douglas B. Staple

In a project using SciPy and NumPy, should I use scipy.pi, numpy.pi, or math.pi?

Now we will see solution for issue: Should I use scipy.pi, numpy.pi, or math.pi?


Answer

>>> import math
>>> import numpy as np
>>> import scipy
>>> math.pi == np.pi == scipy.pi
True

So it doesn’t matter, they are all the same value.

The only reason all three modules provide a pi value is so if you are using just one of the three modules, you can conveniently have access to pi without having to import another module. They’re not providing different values for pi.

This question is answered By – BrenBarn

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0