Python | sympy.is_nonnegative() method
Last Updated :
08 Feb, 2023
In sympy 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:
Python3
from sympy import *
geek1 = simplify( - 21 ).is_nonnegative
geek2 = simplify( 0 ).is_nonnegative
print (geek1)
print (geek2)
|
Output:
False
True
Code #2:
Python3
from sympy import *
geek1 = simplify( - 0.2 ).is_nonnegative
geek2 = simplify( 45 / 8 ).is_nonnegative
print (geek1)
print (geek2)
|
Output:
False
True
Share your thoughts in the comments
Please Login to comment...