Advertisement
Toma252

4.3 quadratic equation 2

Oct 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #This program calculates possible solutions for a quadratic equation#
  2. #####################################################################
  3.  
  4. # Coefficients of quadratic equation
  5. a = float(input("Enter quadratic coefficient: "))
  6. b = float(input("Enter linear coefficient: "))
  7. c = float(input("Enter constant coefficient: "))
  8.  
  9. # Discriminant for calculating x
  10. D = b * b - 4 * a * c
  11.  
  12. # Square root of discriminant
  13. d = D ** 0.5
  14.  
  15. # Possible results
  16. x = (-b - d) / (2 * a)
  17. y = (-b + d) / (2 * a)
  18.  
  19. result = (x, y)
  20.  
  21. # Print the result
  22. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement