np.isfinite_带有Python示例的math.isfinite()方法

np.isfinite

Python math.isfinite()方法 (Python math.isfinite() method)

math.isfinite() method is a library method of math module, it is used to check whether a given number is a finite number of not, it accepts a number (integer/float, finite, infinite or NaN), and returns True if number neither an infinity nor a NaN (Not A Number), else it returns False.

math.isfinite()方法数学模块的库方法,用于检查给定数是否为not的有限数,它接受数字(整数/浮点数,有限,无限或NaN),如果满足,则返回True既不是无穷大也不是NaN(不是数字),否则返回False 。

Syntax of math.isfinite() method:

math.isfinite()方法的语法:

    math.isfinite(n)

Parameter(s): n – a number that has to be checked whether it is finite or not.

参数: n –一个必须检查其是否有限的数字。

Return value: bool – it returns a Boolean ("True" or "False") value.

返回值: bool –返回布尔值(“ True”或“ False”)。

Example:

例:

    Input:
    a = 10
    b = float('inf')

    # function call
    print(math.isfinite(a))
    print(math.isfinite(b))

    Output:
    True
    False

Python代码演示math.isfinite()方法的示例 (Python code to demonstrate example of math.isfinite() method)

# python code to demonstrate example of 
# math.isfinite() method

# importing math module
import math

# math.isfinite() method test on finite value
print(math.isfinite(10))
print(math.isfinite(0))
print(math.isfinite(10.23))
print(math.isfinite(0.0))

# math.isfinite() method test on infinite value
print(math.isfinite(float('inf')))
print(math.isfinite(float('-inf')))
print(math.isfinite(float('nan')))

Output

输出量

True
True
True
True
False
False
False

Recommended posts

推荐的帖子

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

np.isfinite

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值