Python | sympy.is_nonzero() method
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
from sympy import *
geek1 = simplify( 21 ).is_nonzero
geek2 = simplify( 0 ).is_nonzero
print (geek1)
print (geek2)
|
Output:
True
False
Code #2:
Python3
from sympy import *
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
Share your thoughts in the comments
Please Login to comment...