Skip to content

Instantly share code, notes, and snippets.

@DevLord-Avijit
Created February 28, 2023 12:11
Show Gist options
  • Select an option

  • Save DevLord-Avijit/4c74e5c5f1ff1246c27ab86414e4e0f7 to your computer and use it in GitHub Desktop.

Select an option

Save DevLord-Avijit/4c74e5c5f1ff1246c27ab86414e4e0f7 to your computer and use it in GitHub Desktop.
Python program to find out Quadratic equation
# Solve the quadratic equation ax**2 + bx + c = 0
# import complex math module
import cmath
a = 1
b = 5
c = 6
# 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment