Python | sympy.as_coefficient() method
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.
# import sympy from sympy import * x = symbols('x') # Use sympy.as_coefficient() method gfg = x**3 + 21 * x + 12 print(gfg.as_coefficient(x)) |
Output :
21
Example #2 :
# import sympy from sympy import * x = symbols('x') # Use sympy.as_coefficient() method gfg = x**3 + 21 * x**2 + 121x + 4 print(gfg.as_coefficient(x)) |
Output :
121
Recommended Posts:
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.waitid() method
- Python | shutil.which() method
- Python PIL | getpalette() Method
- Python PIL | getcolors() Method
- Python | os.WIFEXITED() method
- Python | Tensorflow cos() method
- Python | os.major() method
- Python | os.stat() method
- Python | os.minor() method
- Python | os.fstat() method
- Python | os.umask() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



