我有以下代码:
class Quadratic:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def function(self, x):
self.F(x) = a*(x**2) + b*x + c
return F(x)
def table(self, lower, upper, varz):
inc = np.absolute(upper-lower) / varz
print inc
for i in range(0 , varz - 1):
self.F(lower)
lower = lower + inc
#lower bound,upper bound, number of values
def roots():
x1 = (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)
x2 = (-b - math.sqrt(b**2 - 4*a*c)) / (2*a)
return x1, x2
def dump(self):
print self.n
每当我尝试运行此脚本时,都会得到以下结果:
^{pr2}$任何帮助或想法都将不胜感激。在
目前还不清楚(至少对我来说)你想要达到的目标是什么,但也许就这么简单:
尝试使用:
并放弃function()方法
您可能已经猜到,
F(x)
是一个函数调用。您调用的函数F
,它实际上并不存在,并向它传递参数x
,它实际上也不存在。您需要给变量提供合法的名称,比如f_of_x
。在相关问题 更多 >
编程相关推荐