如何解决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)
the decription of my code and the ungiven output
解决方法
将变量分配给积分器,如下:
i=integrator(1,2,-3)
print(i)
应该可以
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。