Answered step by step
Verified Expert Solution
Link Copied!

Question

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

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 ax? + = 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.4142 56, 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 to Expert-Tailored 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

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Discuss whether we can control stereotyping.

Answered: 1 week ago