13.07.2023 AIM: To write a program to find the roots of a quadratic equation.
CODE:
import cmath print('The roots are imaginary.')
a=eval(input('Enter coefficient of x square: sq=cmath.sqrt(d) ')) x1=(-b+sq)/(2*a) b=eval(input('Enter coefficient of x:')) if x1.imag==0: c=eval(input('Enter constant term:')) x1=x1.real d=(b**2)-(4*a*c) x2=(-b-sq)/(2*a) if d==0: if x2.imag==0: print('The roots are real and equal.') x2=x2.real elif d>0: print('Roots of equation are',x1,'and',x2,'.') print('The roots are real and distinct.') elif d<0: