Quadratic Equation Program:-
The Standard Form of a Quadratic Equation looks like this
Quadratic Equation: ax**2 + bx + c = 0
a, b and c are known values. a can’t be 0.
“x” is the variable or unknown
When the Discriminant (b2−4ac) is:
- positive, there are 2 real solutions
- zero, there is one real solution
- negative, there are 2 complex solutions
import cmath a = 1 b = 6 c = 8 # calculating discriminant d = (b**2) - (4*a*c) # findinf\g solutions solution1 = (-b-cmath.sqrt(d))/(2*a) solution2 = (-b+cmath.sqrt(d))/(2*a) print(' solutions are {0} and {1}'.format(solution1,solution2))
Output Is:-