Sunday, November 17, 2024
Google search engine
HomeLanguagesPython | sympy.is_nonnegative() method

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 module
from sympy import *
 
# calling is_nonnegative function on different numbers
geek1 = simplify(-21).is_nonnegative
geek2 = simplify(0).is_nonnegative
 
print(geek1)
print(geek2)


Output: 

False
True

Code #2: 

Python3




# Python program to check nonnegative number
# using sympy.is_nonnegative() method
 
# importing sympy module
from sympy import *
 
# calling is_negative function on different numbers
geek1 = simplify(-0.2).is_nonnegative
geek2 = simplify(45/8).is_nonnegative
 
print(geek1)
print(geek2)


Output: 

False
True

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments