Python| sympy.is_positive() 方法
在 simpy 模块中,我们可以使用sympy.is_positive()
函数测试给定数字 n 是否为正数。
Syntax: sympy.is_positive(n)
Parameter: n; number to be tested
Return: bool value result
代码#1:
输出:
Python3
# Python program to check positive number
# using sympy.is_positive() method
# importing sympy module
from sympy import *
# calling is_positive function on different numbers
geek1 = simplify(-21).is_positive
geek2 = simplify(0).is_positive
print(geek1)
print(geek2)
Python3
# Python program to check positive number
# using sympy.is_positive() method
# importing sympy module
from sympy import *
# calling is_positive function on different numbers
geek = simplify(-002).is_positive
print(geek)
输出:
False
True
代码#2:
Python3
# Python program to check positive number
# using sympy.is_positive() method
# importing sympy module
from sympy import *
# calling is_positive function on different numbers
geek = simplify(-002).is_positive
print(geek)
输出:
False
在评论中写代码?请使用 ide.geeksforgeeks.org,生成链接并在此处分享链接。