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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started