phyon解一元二次方程
ax^2+bx+c=0求x1,x2,无解
(有过程和结果就行) ```py
import math
def calcEquation(a, b, c):
discriminant = b**2 - 4*a*c
if discriminant > 0:
root1 = (-b + math.sqrt(discriminant)) / (2*a)
root2 = (-b - math.sqrt(discriminant)) / (2*a)
return root1, root2
elif discriminant == 0:
root = -b / (2*a)
return root
else:
return None
a = 1
b = -10
c = 24
roots = calcEquation(a, b, c)
print(roots)
```
页:
[1]