Question: (Algebra: solve quadratic equations) Write a function for solving a quadratic equation using the following header: def solveQuadratic(eqn, roots): The coefficients of a quadratic equation

(Algebra: solve quadratic equations) Write a function for solving a quadratic equation using the following header:

def solveQuadratic(eqn, roots):

The coefficients of a quadratic equation are passed to the list eqn and the noncomplex roots are stored in roots. The function returns the number of roots. Write a program that prompts the user to enter values for a, b, and c and displays the number of roots and all noncomplex roots.

Sample Runs:

Enter a, b, c: 1.0, 3, 1

The roots are -0.381966 and -2.61803

Enter a, b, c: 1, 2.0, 1

The root is -1

Enter a, b, c: 1, 2, 3

The equation has no real roots

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!