Friday, January 10, 2025
Google search engine
HomeLanguagesPython | sympy.is_zero() method

Python | sympy.is_zero() method

In the sympy module, we can test whether a given number n is zero or not using sympy.is_zero() function.

Syntax:  sympy.is_zero(n)
Parameter:  n; number to be tested
Return:  bool value result 

Code #1: 

Python3




# Python program to check zero
# using sympy.is_zero() method
 
# importing sympy module
from sympy import *
 
# calling is_zero function on different numbers
geek1 = simplify(1).is_zero
geek2 = simplify(0).is_zero
 
print(geek1)
print(geek2)


Output:  

False
True

Code #2: 

Python3




# Python program to check negative number
# using sympy.is_negative() method
 
# importing sympy module
from sympy import *
 
# calling is_negative function on different numbers
geek1 = simplify(0.0).is_zero
geek2 = simplify(2).is_zero
 
 
print(geek1)
print(geek2)


Output: 

True
False

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