python變量和常量
Python數學模塊常量 (Python math module constants)
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 python programming language, there are following math module constants.
在python編程語言中 ,有以下數學模塊常量 。
數學模塊/庫的常數列表 (List of constants of math module/library )
Sr. | Keyword | Description |
---|---|---|
1 | math.pi | It returns the value of mathematics constant PI (π), the value is 3.141592... |
2 | math.e | It returns the value of mathematical constant e, the value is 2.718281... |
3 | math.tau | It returns the value of mathematical constant TAU (τ), the value is 6.283185... |
4 | math.inf | It returns the floating-point positive infinity, -math.inf is used to get the floating-point negative infinity. |
5 | math.nan | 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 。 |
Python代碼演示數學模塊常量的示例 (Python code to demonstrate example of math module constants)
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 module
import math
# printing value of PI
print("value of pi = ", math.pi)
# printing value of e
print("value of e = ", math.e)
# printing value of tau
print("value of tau = ", math.tau)
# printing value of infinity
print("value of +ve inf = ", math.inf)
print("value of -ve inf = ", -math.inf)
# printing value of nan
print("value of nan = ", math.nan)
Output
輸出量
value of pi = 3.141592653589793
value of e = 2.718281828459045
value of tau = 6.283185307179586
value of +ve inf = inf
value of -ve inf = -inf
value of nan = nan
翻譯自: https://www.includehelp.com/python/math-module-constants-with-examples.aspx
python變量和常量