求助求助,个人感觉程序没有错误,为什么运行出错,用的notepad++
import math
def quadratic_equation(a, b, c):
y = b*b - 4*a*c
if y < 0:
return
else:
x1 = (-b+math.sqr(y))/(2*a)
x2 = (-b-math.sqr(y))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
cmd显示如下:
F:\PythonTest>python test.py
Traceback (most recent call last):
File "test.py", line 12, in <module>
print quadratic_equation(2,3,0)
File "test.py", line 9, in quadratic_equation
x1 = (-b+math.sqr(y))/(2*a)
AttributeError: 'module' object has no attribute 'sqr'