猿问

python Spyder 交互式输出

最近我写了这段代码,试图找到一些方法来计算抛物线的积分,但现在对我来说这不是任何问题,但关键是我写的代码没有给我任何输出,这很奇怪我使用 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)

我的代码的描述和未给出的输出


慕无忌1623718
浏览 145回答 1
1回答

MYYA

将变量分配给积分器为:i=integrator(1,2,-3)print(i)那应该有用
随时随地看视频慕课网APP

相关分类

Python
我要回答