Friday, October 10, 2025
HomeLanguagesPython | sympy.as_two_terms() method

Python | sympy.as_two_terms() method

With the help of sympy.as_two_terms() method, we can separate the mathematical expression by constant value in the mathematical expression and return a tuple by using sympy.as_two_terms() method.

Syntax : sympy.as_two_terms()
Return : Return the tuple of elements separated by constant value.

Example #1 :
In this example we can see that by using sympy.as_two_terms() method, we are able to get the tuple of elements separated by constant value.




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Using sympy.as_two_terms() method
gfg = (3 * x + 5 * y + 6).as_two_terms()
  
print(gfg)


Output :

(6, 3*x + 5*y)

Example #2 :




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Using sympy.as_two_terms() method
gfg = (x**2 + 4).as_two_terms()
  
print(gfg)


Output :

(4, x**2)

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

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS