write a python program to find all roots of a quadratic equation
Answers
Answer:
Explanation:
The standard form of a quadratic equation is:
Enter a: 1
Enter b: 5
Enter c: 6
The solutions are (-3+0j) and (-2+0j)
This program computes roots of quadratic equations when coefficients of a,b and c are known.
The standard form of Quadratic Equation is:
ax² + bx + c = 0 where,
a,b and c are real numbers and a ≠ b
⠀⠀⠀: So let's cöde for this program :
a=int(input("Enter a: "))
b=int(input("Enter b: "))
c=int(input("Enter c: "))
D=(b* *2)-(4*a*c)
print("The value of discriminant is",D)
sol1 = (-b+D* *0.5/2*a)
sol2 = (+b-D* *0.5/2*a)
print("The roots of this quadratic equations are", sol1, "and" ,sol2)
Here first , we need to find the discriminant and then roots.
Note: You can change the values of a ,b and c in the above program to test its output .
![](https://hi-static.z-dn.net/files/d08/dff08fb9e873283dca347245fdb2b137.jpg)
![](https://hi-static.z-dn.net/files/dda/6e9d3b316b677ac8509297ae430f3fc3.jpg)