Open In App

Python | sympy.is_negative() method

Last Updated : 08 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads