Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #Quadratic formula calculator
  2. #Samuel Lai
  3.  
  4. a = float(input("Give me your 'a' value please"))
  5. b = float(input("Give me your 'b' value please"))
  6. c = float(input("Give me your 'c' value please"))
  7.  
  8. b = -b
  9. discriminant = b**2-4*a*c
  10.  
  11. a = 2 * a
  12. answerpos = float(b + (discriminant ** .5)) / float(a)
  13. answerneg = float(b - (discriminant ** .5)) / float(a)
  14.  
  15. if discriminant == 0:
  16. print("There is one solution")
  17. print("The solution is",answerpos,)
  18.  
  19. elif discriminant < 0:
  20. print("There are no solutions")
  21.  
  22. else:
  23. print("There are two solutions")
  24. a = 2 * a
  25. answerpos = float(b + (discriminant ** .5)) / float(a)
  26. answerneg = float(b - (discriminant ** .5)) / float(a)
  27. print("The solutions are",answerpos, "and",answerneg,)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement