Python Program
Python Program
The following program is a demonstration of the quadratic calculation. For ax^2+bx+c, what's the roots x . For no real roots, print no real roots. And for a=0 ,calculate in method of linear equation.
import math
a=int(input('enter a:'))
b=int(input('enter b:'))
c=int(input('enter c:'))
if a=0:
print("its not a quadratic equation")
n=-c/b
print(n)
if (b*b-4*a*c) < 0:
print ("no real roots")
else:
x1=(-b + math.sqrt(b*b-4*a*c))/(2*a)
x2=(-b - math.sqrt(b*b-4*a*c))/(2*a)
print(x1,x2)