Python sympy.is_nonpositive()方法
在simpy模块中,我们可以使用sympy.is_nonpositive()函数来测试一个给定的数字n是否为非正数。
语法: sympy.is_nonpositive(n)
参数 : n; 待测数
返回: bool value result
代码 #1:
# Python program to check non-positive number
# using sympy.is_nonpositive() method
# importing sympy module
from sympy import *
# calling is_nonpositive function on different numbers
geek1 = simplify(-21).is_nonpositive
geek2 = simplify(0).is_nonpositive
print(geek1)
print(geek2)
输出:
True
False
代码 #2:
# Python program to check non-positive number
# using sympy.is_nonpositive() method
# importing sympy module
from sympy import *
# calling is_nonpositive function on different numbers
geek = simplify(-002).is_nonpositive
print(geek)
输出:
True