Skip to content
Related Articles

Related Articles

Python | sympy.symbols() method
  • Last Updated : 02 Aug, 2019

With the help of sympy.symbols() method, we can declare some variables for the use of mathematical expression and polynomials by using sympy.symbols() method.

Syntax : sympy.symbols()
Return : Return nothing or None.

Example #1 :
In this example we can see that by using sympy.symbols() method, we are able to get the variables for mathematical expression and polynomials.




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

Output :

16



Example #2 :




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

Output :

30

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :