回溯(最近一次呼叫最后一次): 文件“DS”,第22行,在 打印(“x1=”+str(xone)) NameError:未定义名称“xone”
a=浮动(输入(“bччччччччa:”)
b=浮动(输入(“bчччччччb:”)
c=浮动(输入(“bчччччччc:”)
D=(b*b)-4*a*c
如果D>;0:
xone=(-b+(D/D))/2*a
xtwo=(-b-(D/D))/2*a
打印(“D=“+str(D))
打印(“x1=”+str(xone))
打印(“x2=“+str(xtwo))
如果D==0:
x=-b/(2*a)
打印(“D=“+str(D))
打印(“x=”+str(x))
如果D<;0:
打印(“D=“+str(D))
打印(“没有x1和x2!”)
你遇到了问题
在D不大于0的情况下,xone没有定义。因此,当您到达第22行的
print ( " x1 = " + str(xone))
时,xone没有定义,因此给出了这个NameError建议:
建议2,保持代码样式不变:
相关问题 更多 >
编程相关推荐