求一元二次方程:ax^2+bx+c=0的解,为啥不对
import math
def quadratic_equation(a, b, c):
tmp = b * b - 4 * a * c
if tmp < 0:
return
elif tmp == 0:
return -b/(2 * a)
else:
x1= (-b + math.sqrt(tmp))/(2*a)
x2= (-b - math.sqrt(tmp))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)