Skip to content

Instantly share code, notes, and snippets.

@Armen-Jean-Andreasian
Created June 7, 2023 15:14
Show Gist options
  • Save Armen-Jean-Andreasian/e07aeb2f36d4b41f82dc1bfd0ad5283a to your computer and use it in GitHub Desktop.
Save Armen-Jean-Andreasian/e07aeb2f36d4b41f82dc1bfd0ad5283a to your computer and use it in GitHub Desktop.
# x**2 + 5x + 4 = 0
a = 1
b = 5
c = 4
D = b**2 - 4*a*c
if D > 0:
x_1 = ((-1 * b) + D**(1/2)) / 2 * a
x_2 = ((-1 * b) - D**(1/2)) / 2 * a
print(x_1, x_2)
elif D == 0:
x = (-1*b) / 2 * a
print(x)
elif D > 0:
print("No roots")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment