Friday, September 5, 2025
HomeLanguagesPython | sympy.is_positive() method

Python | sympy.is_positive() method

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




# 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)


Output:

False
True

Code #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(-0o2).is_positive
 
print(geek)


Output:

False

 Code #3:

 The sum of  two positive terms is positive

Python3




# importing sympy library
from sympy import *
from sympy import symbols
a, b = symbols('a, b', positive=True)
 
geek = a + b
 
print(geek.is_positive)


Output:

True
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32269 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6636 POSTS0 COMMENTS
Nicole Veronica
11802 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11865 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7027 POSTS0 COMMENTS
Thapelo Manthata
6703 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS