Python | sympy.is_nonnegative() method

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

Syntax:  sympy.is_nonnegative(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 nonnegative number 
# using sympy.is_nonnegative() method
  
# importing sympy module
from sympy import *
  
# calling is_nonnegative function on differnet numbers
geek1 = simplify(-21).is_nonnegative
geek2 = simplify(0).is_nonnegative
  
print(geek1)
print(geek2)

chevron_right


Output:



False
True

Code #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

False


My Personal Notes arrow_drop_up

Recommended Posts:



    Article Tags :

    Be the First to upvote.


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