Python | sympy.as_ordered_terms() method
Last Updated :
26 Jul, 2019
With the help of sympy.as_ordered_terms()
method, we can get the terms ordered by variables by using sympy.as_ordered_terms()
method.
Syntax : sympy.as_ordered_terms()
Return : Return ordered terms in mathematical expression.
Example #1 :
In this example we can see that by using sympy.as_ordered_terms()
method, we are able to get the terms of mathematical expression.
from sympy import *
x, y = symbols( 'x y' )
gfg = (x * * 2 + 2 * x * y + y * * 2 ).as_ordered_terms()
print (gfg)
|
Output :
[x**2, 2*x*y, y**2]
Example #2 :
from sympy import *
x, y = symbols( 'x y' )
gfg = (y + x).as_ordered_terms()
print (gfg)
|
Output :
[x, y]
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...