Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. a = int(input("Enter the coefficients of a: "))
  2. b = int(input("Enter the coefficients of b: "))
  3. c = int(input("Enter the coefficients of c: "))
  4.  
  5. d = b**2-4*a*c # discriminant
  6.  
  7. if d < 0:
  8. print ("This equation has no real solution")
  9. elif d == 0:
  10. x = (-b+math.sqrt(b**2-4*a*c))/2*a
  11. print ("This equation has one solutions: "), x
  12. else:
  13. x1 = (-b+math.sqrt((b**2)-(4*(a*c))))/(2*a)
  14. x2 = (-b-math.sqrt((b**2)-(4*(a*c))))/(2*a)
  15. print ("This equation has two solutions: ", x1, " or", x2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement