本文共 1868 字,大约阅读时间需要 6 分钟。
python变量和常量
In the math module, there are some of the defined constants that can be used for various mathematical operations, these are the mathematical constants and returns their values equivalent to their standard defined values.
在数学模块中,有一些定义的常数可用于各种数学运算,这些是数学常数,它们返回的值等于其标准定义值。
In , there are following math module constants.
在 ,有以下数学模块常量 。
Sr. | Keyword | Description |
---|---|---|
1 | It returns the value of mathematics constant PI (π), the value is 3.141592... | |
2 | It returns the value of mathematical constant e, the value is 2.718281... | |
3 | It returns the value of mathematical constant TAU (τ), the value is 6.283185... | |
4 | It returns the floating-point positive infinity, -math.inf is used to get the floating-point negative infinity. | |
5 | It returns the floating-point nan (Not a Number), the value is nan. |
高级 | 关键词 | 描述 |
---|---|---|
1个 | 它返回数学常数PI( π )的值,该值为3.141592 ... | |
2 | 它返回数学常数e的值,该值为2.718281 ... | |
3 | 它返回数学常数TAU( τ )的值,该值为6.283185 ... | |
4 | 它返回浮点正无穷大, -math.inf用于获取浮点负无穷大。 | |
5 | 它返回浮点nan (不是数字),值为nan 。 |
In this example, we are printing the value of all constants of python math module.
在此示例中,我们将打印python math模块的所有常量的值。
# python code to demonstrate example of # math module constants# importing math moduleimport math # printing value of PIprint("value of pi = ", math.pi)# printing value of eprint("value of e = ", math.e)# printing value of tauprint("value of tau = ", math.tau)# printing value of infinityprint("value of +ve inf = ", math.inf)print("value of -ve inf = ", -math.inf)# printing value of nanprint("value of nan = ", math.nan)
Output
输出量
value of pi = 3.141592653589793value of e = 2.718281828459045value of tau = 6.283185307179586value of +ve inf = infvalue of -ve inf = -inf value of nan = nan
翻译自:
python变量和常量
转载地址:http://kyxzd.baihongyu.com/