黄金比例是在Python中定义的吗? [英] Is the golden ratio defined in Python?
本文介绍了黄金比例是在Python中定义的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在标准python模块中获取黄金分割率 phi
?我知道 math
模块中的 e
和 pi
,但是我可能有缺少在某处定义的 phi
.
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.
推荐答案
scipy.constants
将黄金比例定义为 scipy.constants.golden
.在标准库中没有定义它,大概是因为它很容易定义自己:
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
这篇关于黄金比例是在Python中定义的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文