Answer:
import math
print("Let's solve ax² + bx + c = 0")
a = int(float(input('Enter a value for a: ')))
b = int(float(input('Enter a value for b: ')))
c = int(float(input('Enter a value for c: ')))
D = b*b-4*a*c
if (D<0):
print("Sorry, this equation has no solutions.")
elif (a == 0):
if (b == 0):
if (c == 0):
print("Every value of x is a solution")
else:
print("Sorry, this equation has no solutions")
else:
x = -c/b
print("The one solution is x={:.3g}".format(x))
elif (D==0):
x = (-b + math.sqrt(D)) / (2*a)
print("The one solution is x={:.3g}".format(x))
else:
x1 = (-b + math.sqrt(D)) / (2*a)
x2 = (-b - math.sqrt(D)) / (2*a)
print("This equation has two solutions: x={:.3g} or x={:.3g}".format(x1, x2))
Step-by-step explanation:
Above is another little program to use the quadratic formula.