fork download
  1. import math
  2.  
  3. def rootsQEq():
  4. print("This program finds the real solutions to a quadratic.")
  5. print()
  6.  
  7. a = 2
  8. b = -5
  9. c = 3
  10. #To call a function from the math library, we can use the
  11. #dot operator as follows:
  12. s_root_val = math.sqrt(b*b - 4 * a * c)
  13. root1 = (-b + s_root_val)/(2*a)
  14. root2 = (-b - s_root_val)/(2*a)
  15.  
  16. print()
  17. print("The solutions are: ", root1, root2)
  18.  
  19. #Call the function rootsQEq()
  20. rootsQEq()
  21.  
  22.  
  23.  
Success #stdin #stdout 0.13s 14088KB
stdin
Standard input is empty
stdout
This program finds the real solutions to a quadratic.


The solutions are:  1.5 1.0