Question: 3. Produce the function quadratic(a,b,c) where a, b, and c are the coeffi- cients of the quadratic ax2 + bx +c. The function should return:

 3. Produce the function quadratic(a,b,c) where a, b, and c are

3. Produce the function quadratic(a,b,c) where a, b, and c are the coeffi- cients of the quadratic ax2 + bx +c. The function should return: 1. a list of the two roots of ax2 + bx +c= 0, when two roots exist 2. the first root is the smaller of the two 3. if ax2 + bx +c=0 has no real roots, then return None. 4. if the quadratic has one real root only, then return a list with a single element in it. Some test cases: print (quadratic(1,2,3))# Should be None print(quadratic(1,-2, 1)) # Should be [1.0] print (quadratic(1,0,-2)) # Should be [-1.41421356, 1.41421356] You are allowed to import from math module/library the built in square root function math.sqrt(). [1%]

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!