参考代码
import math
def quadratic_equation(a, b, c):
d=math.sqrt(b*b-4*a*c)
return (-b+d)/(2*a),(-b-d)/(2*a)
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
参考输出
(0.0, -1.5)
(5.0, 1.0)
参考代码
import math
def quadratic_equation(a, b, c):
d=math.sqrt(b*b-4*a*c)
return (-b+d)/(2*a),(-b-d)/(2*a)
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
参考输出
(0.0, -1.5)
(5.0, 1.0)
2014-10-04
举报