Python | sympy.is_positive() method
Last Updated :
08 Feb, 2023
In sympy module, we can test whether a given number n is positive or not using sympy.is_positive() function.
Syntax: sympy.is_positive(n)
Parameter: n; number to be tested
Return: bool value result
Code #1:
Python3
from sympy import *
geek1 = simplify( - 21 ).is_positive
geek2 = simplify( 0 ).is_positive
print (geek1)
print (geek2)
|
Output:
False
True
Code #2:
Python3
from sympy import *
geek = simplify( - 0o2 ).is_positive
print (geek)
|
Output:
False
Code #3:
The sum of two positive terms is positive
Python3
from sympy import *
from sympy import symbols
a, b = symbols( 'a, b' , positive = True )
geek = a + b
print (geek.is_positive)
|
Output:
True
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...