mdelatorre icon

Quadratic Equation in Python

mdelatorre | PRO | 10/01/20 02:51:46 AM UTC | 0 ⭐ | 923 👁️ | Never ⏰ | []
Python |

360 B

|

None

|

0 👍

/

0 👎

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