Is there a way to get the golden ratio, phi
, in the standard python module? I know of e
and pi
in the math
module, but I might have missed phi
defined somewhere.
Advertisement
Answer
scipy.constants
defines the golden ratio as scipy.constants.golden
. It is nowhere defined in the standard library, presumably because it is easy to define yourself:
golden = (1 + 5 ** 0.5) / 2