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

Write a python program that will calculate and output roots of a quadratic equat

ID: 3664995 • Letter: W

Question

Write a python program that will calculate and output roots of a quadratic equation.

The formula will be written on the board in class.

Values for a, b and c should be input into three floating point variables.

Your program should first display:

Hello…

This program will ask you to enter 3numbers

(a, b and c) that will be used in the quadratic formula to

calculate the roots of an equation.

Enter a value for a

Enter a value for b

Enter a value for c

Validate your data ( make sure a is not zero and b.b>4.a.c )

Your program should display:

***************************************

* Root 1 is the value of root1 *

* Root 2 is the value of root2 *

***************************************

Use format to print root1 & root2 in a field of 7 positions with one digit after decimal point

Explanation / Answer

Solve the quadratic equation ax**2 + bx + c = 0 # Coeffients a, b and c are provided by the user # import complex math module import cmath print('hello') a = float(input('Enter a: ')) b = float(input('Enter b: ')) c = float(input('Enter c: ')) # calculate the discriminant d = (b**2) - (4*a*c) # find two solutions sol1 = (-b-cmath.sqrt(d))/(2*a) sol2 = (-b+cmath.sqrt(d))/(2*a) print('The solution are {0} and {1}'.format(sol1,sol2))

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