Python | sympy.is_nonnegative() method

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
# Python program to check nonnegative number # using sympy.is_nonnegative() method# importing sympy modulefrom sympy import *# calling is_nonnegative function on different numbersgeek1 = simplify(-21).is_nonnegativegeek2 = simplify(0).is_nonnegativeprint(geek1)print(geek2) |
Output:
False True
Code #2:
Python3
# Python program to check nonnegative number # using sympy.is_nonnegative() method# importing sympy modulefrom sympy import *# calling is_negative function on different numbersgeek1 = simplify(-0.2).is_nonnegativegeek2 = simplify(45/8).is_nonnegativeprint(geek1)print(geek2) |
Output:
False True



