python Spyder 交互输出

python Spyder interactive output

最近我写了这段代码,试图找到一些方法来计算抛物线的积分,但这对我来说现在没有任何问题,但关键是我写的代码没有给我任何输出,这很奇怪我用的是spyder,代码如下:

def integrator(a,b,c):
    #a,b and c are the factors of the quadratic
    import numpy as np
    delta=((b**2)-4*a*c)
    answer1= (-b+delta)/2
    answer2=(-b-delta)/2 
    #it gets the answers of the quadratic eruation and uses them as the lower and upper bounds
    if delta<=0:
        return "this func has no real answer"
    if delta==0:
        return "this function has two equal answers"
        return  answer1
  else:
      return answer1
      return answer2
  #it also calculate the answers of the quadratic equation too
  integ_range=[]
  for i in np.arange(answer1,answer2,0.01):
      integ_range.append(i)
  for i in integ_range:
      heights=(a*(i**2))+(b*i)+c
  sum1=sum(integ_range)    
  integrate=sum1*0.01
  return (integrate)

integrator(1,2,3)

the decription of my code and the ungiven output

将变量分配给积分器为:

i=integrator(1,2,-3)
print(i)

应该可行