Site icon Matistics

Python – program to find out the Roots of a QUADRATIC Equation considering real and imaginary roots

a=int(input("enter coefficient of x^2\n"))
b=int(input("enter the coefficient of x\n"))
c=int(input("enter the coefficient of x^0\n"))
d =(b**2 - 4*a*c)
if(d<0):
e =((-d)**0.5)/2*a
f =-b/2*a
print(f"Imaginary roots of {a}x^2+{b}x+{c}=0 are {f}+i{e} and {f}-i{e}.")
else:
x1=( -b + (d)**0.5 )/2*a
x2=( -b - (d)**0.5 )/2*a
print(f"the roots of {a}x^2+{b}x+{c}=0 are {x1} and {x2}.")
Exit mobile version