Python program to solve quadratic equation

Опубликовано: 12 Май 2026
на канале: CodeLSC
241
1

Visit codepro.blog 🌐 for complete code examples 💻, additional articles 📚, and more resources 🚀. Python is a simple, general purpose, high level, and object-oriented programming language.

Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming.
----------------------------------------------------------------------------------------------------------------
Python program to solve quadratic equation
#code:

import complex math module
import cmath
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))
----------------------------------------------------------------------------------------------------------------
#pythonprogram
#learnpython
#quadratic_equation
#python_equation
========================================