mdelatorre

Quadratic Equation in Python

Sep 30th, 2020
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = float(input("Enter a: "))
  2. b = float(input("Enter b: "))
  3. c = float(input("Enter c: "))
  4.  
  5. if(math.pow(b,2) -  (4*a*c) >= 0):
  6.     x_1 = (-b  + math.sqrt(math.pow(b,2) -  (4*a*c)))/(2*a)
  7.     x_2 = (-b  - math.sqrt(math.pow(b,2) -  (4*a*c)))/(2*a)
  8.     print("x1 {}  and x2 {}".format(x_1,x_2))
  9. else:
  10.     print("The root of the equation are imaginary numbers")
Add Comment
Please, Sign In to add comment