Python | sympy.as_coefficient() method
Last Updated :
14 Jul, 2019
With the help of sympy.as_coefficient()
method, we can find the coefficient of any element in the mathematical expression by using sympy.as_coefficient()
method.
Syntax : sympy.as_coefficient()
Return : Return the coefficient of any element.
Example #1 :
In this we can see that by using sympy.as_coefficient()
method, we are able to get the values of coefficient of any element that is passed as parameter.
from sympy import *
x = symbols( 'x' )
gfg = x * * 3 + 21 * x + 12
print (gfg.as_coefficient(x))
|
Output :
21
Example #2 :
from sympy import *
x = symbols( 'x' )
gfg = x * * 3 + 21 * x * * 2 + 121x + 4
print (gfg.as_coefficient(x))
|
Output :
121
Share your thoughts in the comments
Please Login to comment...