我非常新的編碼,我應該寫函數g(t)
並得到g(0)
和g(1)
的結果。 我寫代碼,希望能實現這一目標,但我得到的錯誤:實現一個簡單的數學函數 - Python
File "[user code]", line 7, in g TypeError: 'float' object is not callable" and I have no clue how to fix it.
問:
g(t)=exp(−t)sin(πt),
在Python函數g(t)
。打印出g(0)和g(1)。
代碼我寫道:
import math
from math import exp
from math import sin
from math import pi
def g(t):
g=exp(-t)*sin(pi*t)
return (g(0,1))
什麼是你的問題? – miradulo
對不起,我在編碼方面非常新穎,我應該編寫函數g(t)並獲得g(0)和g(1)的結果,我寫了希望實現該目標的代碼,但是我得到錯誤「File」[user code]「,第7行,在g TypeError:'float'對象不可調用」,我不知道如何解決它。 –