Wednesday, July 3, 2024
HomeLanguagesPythonPython | sympy.is_nonzero() method

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




# 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

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments