math.nan常量,带Python示例

Python的math.nan常量是预定义的,存在于math模块中,表示浮点型NaN(非数字)。该常量从Python 3.5开始可用,其语法返回一个浮点值nan。文中提供了一个代码示例来演示其用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Python math.nan常数 (Python math.nan constant)

math.nan constant is a predefined constant, which is defined in the math module, it returns floating-point nan (Not a Number), which is equivalent to float('nan').

math.nan常数是在math模块中定义的预定义常数,它返回浮点nan (不是数字),等效于float('nan') 。

Note: math.nan constant is available from Python 3.5

注意: math.nan常数可从Python 3.5获得

Syntax of math.nan constant:

math.nan常数的语法:

    math.nan

Return value: float It returns a float value (nan) – that is the floating-point "Not a Number".

返回值: float它返回一个浮点值(nan)-浮点数“不是数字”。

Example:

例:

    Input:
    print(math.nan)

    Output:
    nan

Python代码演示math.nan常量示例 (Python code to demonstrate example of math.nan constant)

# python code to demonstrate example of 
# math.nan constant

# importing math module
import math 

# printing value of nan
print("value of NaN = ", math.nan)

Output

输出量

value of NaN = nan

Reference: Python math library

参考: Python数学库

翻译自: https://www.includehelp.com/python/math-nan-constant-with-example.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值