Wednesday, May 6, 2026
HomeLanguagesPython | sympy.as_ordered_terms() method

Python | sympy.as_ordered_terms() method

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.




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


Output :

[x**2, 2*x*y, y**2]

Example #2 :




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.as_ordered_terms() method
gfg = (y + x).as_ordered_terms()
    
print(gfg)


Output :

[x, y]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6890 POSTS0 COMMENTS
Nicole Veronica
12011 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12105 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6962 POSTS0 COMMENTS