Given a quadratic equation ax2 + bx + c = 0, write a function roots(a, b, c) that returns the two roots of the equation. The returned roots should be float objects when the roots are real, otherwise the function returns complex objects. Hint. Use sqrt from the numpy.lib.scimath library, see Chapter 1.6.3. b) Construct two test cases with known solutions, one with real roots and the other with complex roots, Implement the two test cases in two test functions test_roots_float and test_roots_complex, where you call the roots function and check the type and value of the returned objects. Filename: roots_quadratic.
Purchase the answer to view it