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}.")
Scroll to Top
logo
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.