import cmath
a = float(input("Enter coefficient a: "))
b = float(input("Enter coefficient b: "))
c = float(input("Enter coefficient c: "))
# calculate the discriminant
d = (b**2) - (4*a*c)
# find two solutions
sol1 = (-b - cmath.sqrt(d)) / (2*a)
sol2 = (-b + cmath.sqrt(d)) / (2*a)
print("The solutions are {0} and {1}".format(sol1, sol2))
Enter coefficient a: 3
Enter coefficient b: 4
Enter coefficient c: 6
The solutions are (-0.6666666666666666-1.247219128924647j) and (-0.6666666666666666+1.247219128924647j)
(b**2) - (4*a*c)
`.(-b ± sqrt(d)) / (2*a)
`, where `sqrt
` is the square root function provided by the `cmath
` module.-b / (2*a)
`.sqrt
`.