Quadratic Equation in Python
a = float(input("Enter a: "))
b = float(input("Enter b: "))
c = float(input("Enter c: "))
if(math.pow(b,2) - (4*a*c) >= 0):
x_1 = (-b + math.sqrt(math.pow(b,2) - (4*a*c)))/(2*a)
x_2 = (-b - math.sqrt(math.pow(b,2) - (4*a*c)))/(2*a)
print("x1 {} and x2 {}".format(x_1,x_2))
else:
print("The root of the equation are imaginary numbers")
Comments