借助sympy.Lambda()
方法,我們隻需定義公式即可執行任何數學運算,然後使用sympy.Lambda()
。
用法:sympy.Lambda()
返回:Return the result of mathematical formula.
範例1:
在此示例中,我們可以看到,通過使用sympy.Lambda()
方法。
# import sympy
from sympy import *
# Use sympy.Lambda() method
x = symbols('x')
gfg = Lambda(x, x + 1)
print(gfg(9))
輸出:
10
範例2:
# import sympy
from sympy import *
# Use sympy.Lambda() method
x, y = symbols('x y')
gfg = Lambda((x, y), x * y)
print(gfg(9, 5))
輸出:
45
相關用法
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python PIL ImageOps.fit()用法及代碼示例
- Python os.rmdir()用法及代碼示例
- Python sympy.det()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python os.readlink()用法及代碼示例
- Python os.writev()用法及代碼示例
- Python os.readv()用法及代碼示例
- Python PIL RankFilter()用法及代碼示例
- Python os.rename()用法及代碼示例
- Python os.sendfile()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | sympy.Lambda() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。