(Quadratic formula) The formula that calculates roots for a quadratic equation ax2 + bx + c is the quadratic formula
. Because the square root of a negative is imaginary, one can use the expression under the square root (known as the discriminant) to check for the type of root. If the discriminant is negative, the roots are imaginary. If the discriminant is zero, there is only one root. If the discriminant is positive, there are two roots.
(a) Write a program that uses the quadratic formula to generate real roots, i.e., ignores the imaginary roots. Use the discriminant to determine whether there is one root or two roots and then print the appropriate answer.
(b) Python uses the letter “j” to represent the mathematical imaginary number “i” (a convention used in electrical engineering). However, the Python “j” must always be preceeded by a number. That is, “1j” is equivalent to the mathematical “i.” Add the ability to handle imaginary roots to your program.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.