python变量和常量_Python数学模块常量和示例

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.KeywordDescription
1math.piIt returns the value of mathematics constant PI (π), the value is 3.141592...
2math.eIt returns the value of mathematical constant e, the value is 2.718281...
3math.tauIt returns the value of mathematical constant TAU (τ), the value is 6.283185...
4math.infIt returns the floating-point positive infinity, -math.inf is used to get the floating-point negative infinity.
5math.nanIt 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变量和常量

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值