Python | sympy.is_negative() method

In simpy 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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:



True
False

Code #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to check negative number 
# using sympy.is_negative() method
  
# importing sympy module
from sympy import *
  
# calling is_negative function on differnet numbers
geek = simplify(-002).is_negative
  
print(geek)

chevron_right


Output:

True


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.