Advertisement
Toma252

4.3 quadratic equation

Oct 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #This program calculates possible solutions for a quadratic equation#
  2. #####################################################################
  3.  
  4. # Import math library
  5. import math
  6.  
  7. # Coefficients of quadratic equation
  8. a = float(input("Enter quadratic coefficient: "))
  9. b = float(input("Enter linear coefficient: "))
  10. c = float(input("Enter constant coefficient: "))
  11.  
  12. # Discriminant for calculating x
  13. d = b * b - 4 * a * c
  14.  
  15. # Possible results
  16. x = (-b - (math.sqrt(d))) / (2 * a)
  17. y = (-b + (math.sqrt(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