Python | sympy.is_constant() method

With the help of sympy.is_constant() method, we can check if element is constant or not and it will return a boolean value if found constant by using sympy.is_constant() method.

Syntax : sympy.is_constant()
Return : Return a boolean value if constant is found.

Example #1 :
In this example we can see that by using sympy.is_constant() method, we are able to detect the constant by getting boolean value.

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.is_constant() method
gfg = simplify(2).is_constant()
     
print(gfg)

chevron_right


Output :

True



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.is_constant() method
gfg = simplify(sin(x)).is_constant()
     
print(gfg)

chevron_right


Output :

False

My Personal Notes arrow_drop_up

Recommended Posts:

    Article Tags :

    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.