.Write a program to determine the number of roots to a quadratic equation of the
ID: 3619791 • Letter: #
Question
.Write a program to determine the number of roots to a quadratic equation ofthe form:
ax2 + bx + c = 0.
The number of roots is determined by evaluating the formula:
D = b2 - 4ac.
If D < 0, there are no roots; if D = 0, there is one; if D > 0, there are two.
When the program runs, it should look like this:
Enter the coefficients:
a value: 1
b value: 4
c value: 1
D = 12.
There are two roots.
Explanation / Answer
>>def findRoots(a,b,c): D=b*b-4*a*c; print "D = " , D; if D < 0: print "There are no roots"; if D == 0: print "There is one root"; else: print "There are two roots"; >>findRoots(1,4,1);Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.