*write a python program to finds roots of a quadratic equation*
computer chapter-11 python program
please answer my question....
Answers
Answered by
25
Required Answer :
Question:
- Write a python program to finds roots of a quadratic equation.
Program:
# import complex math module
import cmath
# coefficients of a quadratic equation
a = 1
b = 5
c = 6
# calculate the discriminant
d = (b* *2) - (4*a*c)
# find two solutions
root1 = (-b-cmath.sqrt(d))/(2*a)
root2 = (-b+cmath.sqrt(d))/(2*a)
print('The required roots are:')
print(root1)
print(root2)
Output:
The output will be as follows:
The required roots are:
(-3+0j)
(-2+0j)
Attachments:
Mysterioushine:
Great!
Answered by
24
The answer is in the [ATTACHMENT]
I wrote the whole answer but it's not allowing me to post. I don't know what is rude in this.
so refer to the Attachment please.
sorry for the inconvenience.
Attachments:
Similar questions