Thursday, December 18, 2025
HomeLanguagesPython | sympy.is_negative() method

Python | sympy.is_negative() method

In sympy module, we can test whether a given number n is negative or not using sympy.is_negative() function. 

Syntax:  sympy.is_negative(n)
Parameter:  n; number to be tested
Return:  bool value result 

Code #1: 

Python3




# Python program to check negative number
# using sympy.is_negative() method
 
# importing sympy module
from sympy import *
 
# calling is_negative function on different numbers
geek1 = simplify(-21).is_negative
geek2 = simplify(0).is_negative
 
print(geek1)
print(geek2)


Output:  

True
False

Code #2: 

Python3




# Python program to check negative number
# using sympy.is_negative() method
 
# importing sympy module
from sympy import *
 
# calling is_negative function on different numbers
geek1 = simplify(-0.2).is_negative
geek2 = simplify(2).is_negative
 
 
print(geek1)
print(geek2)


Output: 

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

Most Popular

Dominic
32455 POSTS0 COMMENTS
Milvus
108 POSTS0 COMMENTS
Nango Kala
6823 POSTS0 COMMENTS
Nicole Veronica
11958 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12035 POSTS0 COMMENTS
Shaida Kate Naidoo
6958 POSTS0 COMMENTS
Ted Musemwa
7203 POSTS0 COMMENTS
Thapelo Manthata
6910 POSTS0 COMMENTS
Umr Jansen
6890 POSTS0 COMMENTS