下面代码中,把b*b换成b^2为什么就不对了?
import math
def quadratic_equation(a, b, c):
s = math.sqrt(b*b - 4 * a * c)
return (-b + s)/(2*a) , (-b - s)/(2*a)
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
import math
def quadratic_equation(a, b, c):
s = math.sqrt(b*b - 4 * a * c)
return (-b + s)/(2*a) , (-b - s)/(2*a)
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2018-08-31
举报