Discuss / Python / 作业求教。。。

作业求教。。。

Topic source

HYTcrab

#1 Created at ... [Delete] [Delete and Lock User]

照着前面的兄台写了一下,请指点小弟,感激不尽!是哪里出错了啊。。我运行后的结果是 (-2.0, -4.0) (1.0, -4.0) 为什么一个错一个对啊。。。

 if a!=0:
        w = b*b-4*a*c
    if w>=0:
        x1 = (-b + math.sqrt(w))/2*a
        x2 = (-b - math.sqrt(w))/2*a
        return(x1 , x2)
    else:
        return(error)


    pass

iSilent94021

#2 Created at ... [Delete] [Delete and Lock User]

2*a 记得打括号 应该是(2*a)


  • 1

Reply