Question: Using Python! Exercise 3.8: Write a function for solving ax2 + bx + c = 0 a) Given a quadratic equation ax? + bx +

Using Python! Exercise 3.8: Write a function for solving ax2 + bxUsing Python!

Exercise 3.8: Write a function for solving ax2 + bx + c = 0 a) Given a quadratic equation ax? + bx + c = 0, write a function roots(a, b, c) that returns the two roots of the equation. The returned roots should be float-type objects when the roots are real, otherwise complex-type objects. Hint You can test on the sign of the expression in the square root and return stan- dard float or complex Python objects accordingly. Alternatively, you can simply use sqrt from the numpy.lib.scimath library, see Chap. 1.6.3. This sqrt func- tion returns an object of type numpy.complex128 in case of a negative argument (and hence a complex square root) and an object of type numpy.float64 other- wise

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!