Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

math - 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.

question from:https://stackoverflow.com/questions/25212181/is-the-golden-ratio-defined-in-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...