import math
# from abstest import my_abs
def quadratic(a, b, c):
# check input abc is legal
# if not legal throw error
m = b * b - 4 * a * c
if m < 0:
raise TypeError('bad operand type')
return
else:
ret1 = (-b + math.sqrt(m)) / (2 * a)
ret2 = (-b - math.sqrt(m)) / (2 * a)
return ret1, ret2
if quadratic(2, 3, 1) != (-0.5, -1.0):
print('error')
elif quadratic(1, 3, -4) != (1.0, -4.0):
print('error')
else:
print('succ')
08-20
3万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交