📅  最后修改于: 2022-03-11 14:46:04.822000             🧑  作者: Mango
#root of quadratic equation
a=int(input('Enter coefficient of x2 :'))
b=int(input('Enter coefficient of x :'))
c=int(input('Enter the constant :'))
import math as m
if a==0:
print(a,'value of a can not be zero')
print("\n aborting!!!!!!")
else:
delta=b**2- 4*a*c
if delta<0:
root1=((-b + m.sqrt(delta))/(2*a))
root2=((-b - m.sqrt(delta))/(2*a))
print('roots are real and distinct')
print('roots are',root1,'and',root2)
elif delta==0:
root=((-b+ m.sqrt(delta))/(2*a))
print('roots are real and equal')
print('root is',root,'each')
else:
print('roots are imaginary')