+

Python | sympy.is_nonzero () method

In the simpy module, we can check if a given number n is non-zero or not using sympy.is_nonzero () .

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

Code # 1:

# Python program to check for non-nulls
# using the sympy.is_nonzero () method

  
# import sympy module

from sympy import *

  
# calling the is_nonzero function for different numbers

geek1 = simplify ( 21 ). is_nonzero

geek2 = simplify ( 0 ). is_nonzero

 

print (geek1)

print (geek2)

Output:

 True False 

Code # 2:

# Python program to check for a nonzero number
# using the sympy.is_nonzero () method

 
# import sympy module

from sympy import *

  
# calling the is_nonzero function for different numbers

 

geek = simplify ( 002 ). Is_nonzero

 

print (geek)

Output:

 True 
Get Solution for free from DataCamp guru