Skip to content
Related Articles

Related Articles

Python | sympy.Lambda() method
  • Last Updated : 17 Jul, 2019

With the help of sympy.Lambda() method, we can perform any mathematical operation by just defining the formula and then pass the parameters with reference variable by using sympy.Lambda().

Syntax : sympy.Lambda()
Return : Return the result of mathematical formula.

Example #1 :
In this example we can see that we are able to perform any mathematical operation by using sympy.Lambda() method.

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy
from sympy import *
  
# Use sympy.Lambda() method
x = symbols('x')
gfg = Lambda(x, x + 1)
  
print(gfg(9))

chevron_right


Output :

10



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

45

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 :