从ide直接粘贴过来了
Topic sourcedef quadratic(a, b, c):
if not isinstance(a, (int, float)) or not isinstance(b, (int, float) or not isinstance(c, (int, float))):
raise TypeError('bad operand type')
mark = b ** 2 - 4 * a * c
if mark < 0:
print('方程无实根')
return
else:
x1 = (-1 * b + math.sqrt(mark)) / (2 * a)
x2 = (-1 * b - math.sqrt(mark)) / (2 * a)
return x1, x2
- 1
浪过扬帆