Python3 Quadratic Roots
# Python3.x Python Quadratic Equation
[ Python3 Examples](#)
A quadratic equation is of the form: axΒ² + bx + c = 0.
Its solutions can be determined by calculating the discriminant $Delta = b^{2} - 4 a c$Ξ=b 2β4 a c:
1. If $Delta > 0$Ξ>0, the equation has two real roots.
2. If $Delta = 0$Ξ=0, the equation has one real root (a double root).
3. If $Delta < 0$Ξ0:
# Two real roots
root1 =(-b + math.sqrt(delta)) / (2 * a)
root2 =(-b - math.sqrt(delta)) / (2 * a)
return f"The equation has two real roots: x1 = {root1}, x2 = {root2}"
elif delta ==0:
# One real root
root = -b / (2 * a)
return f"The equation has one double real root: x = {root}"
else:
# Two complex roots
root1 =(-b + cmath.sqrt(delta)) / (2 * a)
root2 =(-b - cmath.sqrt(delta)) / (2 *
YouTip