Question: write a python program to calculate the roots of ax 2 + bx + c = 0 Insert a test to cover the special cases

write a python program to calculate the roots of ax2 + bx + c = 0

Insert a test to cover the special cases a = 0 and a = b = 0. (Here it would be nice, but not required, to have your code write the solution to a linear equation.)

Insert a test to quit if the roots are not real.

Compute the roots using the standard formula

 x = [-b +/- sqrt(b^2 - 4*a*c)]/(2*a) 

and using the alternative formula

 x = 2*c/[-b -/+ sqrt(b^2 - 4*a*c)]

run the program for these cases

Then run your program for the cases

 a = 0.02, b = 2, c = 4 a = 2e-8, b = 3, c = 5 a = 2e-8, b = 8, c = 1e-7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!