Open In App

Python | sympy.is_nonzero() method

Improve
Improve
Like Article
Like
Save
Share
Report

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

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

Code #1:  

Python3




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


Output: 

True
False

Code #2: 

Python3




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


Output: 

True
False

Last Updated : 08 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads