Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python, write a code for the following program. 2. Quadratic Equation Writ

ID: 3842350 • Letter: U

Question

Using Python, write a code for the following program.

2. Quadratic Equation Write a program to determine the real roots of the quadratic equation a bx c 0 (where a 0) after requesting the values of a, b, and c x2 Before finding the roots, ensure that a is nonzero. [Note: The equation has 2, 1, or 0 solutions depending on whether the value of b 4ac is positive, zero, or negative. In the first two cases, the solutions are given by the quadratic formula (-b t (b2 4ac)5)/2a.] See Fig. 3.80 on the previous page.

Explanation / Answer

PROGRAM CODE:

import math

def findRoots(a, b, c):
   if a == 0:
       print("a is zero")
   else:
       middle = b*b - 4*a*c;
       sol1 = (-1*b + math.sqrt(middle))/2*a;
       sol2 = (-1*b - math.sqrt(middle))/2*a;
       print(" Soltuons: " + str(sol1) + " and " + str(sol2))

a = int(input('Enter a: '))
b = int(input(' Enter b: '))
c = int(input(' Enter c: '))
findRoots(a,b,c)

OUTPUT:

Enter a: 1
Enter b: -11
Enter c: 28
Soltuons: 7.0 and 4.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote