Skip to content
Advertisement

Is the golden ratio defined in Python?

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
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement