我们如何在 scipy 库中使用各种数学和物理常数?
为了实现科学或数学计算,我们需要各种通用常数。例如,计算圆面积的公式是pi*r*r,其中Pi是一个常数,其值为3.141592653。还有各种其他像这样的场景,我们需要常量。如果我们可以轻松地将这些常数合并到我们的计算中,那真的会很有帮助。在该SciPy的库中,一个子模块,做这项工作为我们提供了我们一个参考材料查找物理常数的详尽名单,通用的数学常数,各单位如SI前缀,二进制的前缀,质量,角,时间等。scipy.constants()
我们可以通过在scipy.constants.name_of_constant中键入常量的名称来访问任何常量的值。例如,如果要访问常量Pi的值,请键入scipy.constants.pi。
示例
#Importing the module
from scipy import constants
#Printing the values of constants
print("The value of sciPy - pi = ", constants.pi)
print("The value of Golden ratio = ", constants.golden_ratio)
print("The value of Speed of light in vaccum = ", constants.c)
print("The value of Gravitational Constant = ", constants.G)
print("The value of Molar Gas Constant = ", constants.R)
print("The value of Boltzman Constant = ", constants.k)
print("The value of Proton mass Constant = ", constants.proton_mass)输出结果The value of sciPy - pi = 3.141592653589793 The value of Golden ratio = 1.618033988749895 The value of Speed of light in vaccum = 299792458.0 The value of Gravitational Constant = 6.6743e-11 The value of Molar Gas Constant = 8.314462618 The value of Boltzman Constant = 1.380649e-23 The value of Proton mass Constant = 1.67262192369e-27
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬