Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Quadratic formula calculator
- #Samuel Lai
- a = float(input("Give me your 'a' value please"))
- b = float(input("Give me your 'b' value please"))
- c = float(input("Give me your 'c' value please"))
- b = -b
- discriminant = b**2-4*a*c
- a = 2 * a
- answerpos = float(b + (discriminant ** .5)) / float(a)
- answerneg = float(b - (discriminant ** .5)) / float(a)
- if discriminant == 0:
- print("There is one solution")
- print("The solution is",answerpos,)
- elif discriminant < 0:
- print("There are no solutions")
- else:
- print("There are two solutions")
- a = 2 * a
- answerpos = float(b + (discriminant ** .5)) / float(a)
- answerneg = float(b - (discriminant ** .5)) / float(a)
- print("The solutions are",answerpos, "and",answerneg,)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement