import math
def main():
print ("let us find the solution to a quadratic\n")
a, b, c=eval(input("please input the coefficients(a,b,c):"))
delta=b*b-4*a*c
if a==0:
x=-b/c
print("\nthere is a solution ",x)
elif delta<0:
print ("\n the solution has no real roots!")
elif delta==0:
x=-b/(2*a)
print ("there is a double root at",x)
else :
delta=math.sqrt(delta)
root1=(-b+delta)/(2*a)
root2=(-b-delta)/(2*a)
print ("\nThe solution are:", root1,root2)
main()
二次方程求解
最新推荐文章于 2021-01-14 21:52:12 发布