Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions