Question: Consider the quadratic equation: A * x**2 + B * x + C = 0 where x is the unknown and A, B and C

Consider the quadratic equation: A * x**2 + B * x + C = 0 where x is the unknown and A, B and C are constants (with A not equal to 0). Note that here we use the Python notation for exponents (two asterisks). A quadratic equation has two solutions (called roots), which may not be distinct values and which may not be real values. The two roots of a quadratic equation may be calculated using the quadratic formula. See the brief article at Wolfram MathWorld if you don't recall the formula: http://mathworld.wolfram.com/QuadraticFormula.html a) Discuss the pseudocode 1. Use variables: A, B, C root1and root2 of type floating-point 2. Input values for A, B and C 3. Print the inputted values for A, B and C 4. Calculate d=sqrt(B*B-4*A*C) 5. Calculate root1=(-B+d)/(2*A) 12 6. Calculate root2=(-B-d)/(2*A) 7. Print root1, root2 8. End Programme. b) Copy the file named "lab01.py" into your computer or you can directly work on it. c) Modify that program to compute the two roots of a quadratic equation, as described in the pseudocode. d) Test your completed program using the following values: A = 1, B = 0, C = -4 Root #1 = ____________ (should be 2.0) Root #2 = ____________ (should be -2.0) A = 1, B = 5, C = -36 Root #1 = ____________ Root #2 = ____________ A = 2, B = 7.5, C = 6 Root #1 = ____________ Root #2 = ____________ A = 0, B = 3.5, C = 8 # this test case fails and generates an error (why?): Root #1 = ____________ Root #2 = ____________

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 Mathematics Questions!