Python Program to Solve Quadratic equation

Python Program to Solve Quadratic equation 

 In this program, you will learn how to calculate the roots of a square equation when the coefficients a, b and c are known.

The quadratic formula uses "a", "b" and "c" from 


where "a", "b" and "c" are just numbers; They are the "numerical modules" of the square equation they have given you to solve.

To understand the following program, you must have the knowledge to follow Python concepts:

Introduction to Python

Basics of Python

For quadratic formula: for 

the values of x which are the solutions of the equation are given as:

Python Program to Solve Quadratic equation

Now take a look at how to write a program to solve Quadratic equation in Python Programming.

Python Code:

import cmath
a = float(input('enter value of a:'))
b = float(input('enter value of b:'))
c = float(input('enter value of c:'))
def h(x):
return h(x)
disc = b**2-4*a*c
root1 = (-b+cmath.sqrt(disc))/2*a
root2 = (-b+cmath.sqrt(disc))/2*a
enter value of a: 49
enter value of b: 9
enter value of c: 36
(-220.5+2046.153403340033j) (-220.5+2046.153403340033j)