This program processes underlying foundations of a quadratic condition when coefficients a, b and c are known.

To comprehend this model, you ought to have the information of following Python programming points:

Python Data Types

Python Input, Output and Import

Python Operators

The standard type of a quadratic condition is:

ax2 + bx + c = 0, where

a, b and c are genuine numbers and

a ≠ 0

Source Code

# Solve the quadratic condition ax**2 + bx + c = 0

# import complex math module

import cmath

a = 1

b = 5

c = 6

# To take coefficient contribution from the clients

# a = float(input('Enter a: '))

# b = float(input('Enter b: '))

# c = float(input('Enter c: '))

# ascertain the discriminant

d = (b**2) - (4*a*c)

# discover two arrangements

sol1 = (- b-cmath.sqrt(d))/(2*a)

sol2 = (- b+cmath.sqrt(d))/(2*a)

print('The arrangement are {0} and {1}'.format(sol1,sol2))

Yield

Enter a: 1

Enter b: 5

Enter c: 6

The arrangements are (- 3+0j) and (- 2+0j)

We have imported the cmath module to perform complex square root. First we ascertain the discriminant and afterward locate the two arrangements of the quadratic condition.

You can change the estimation of a, b and c in the above program and test this program.

Python Program to Calculate the Area of a Triangle