Skip to content

Instantly share code, notes, and snippets.

@ejmurray
Created February 18, 2015 14:19
Show Gist options
  • Save ejmurray/2cf500d31cfe10a84ed9 to your computer and use it in GitHub Desktop.
Save ejmurray/2cf500d31cfe10a84ed9 to your computer and use it in GitHub Desktop.
solves the square root of a triangle
import math
__author__ = 'Ernest'
__project__ = "MySimplePythonApplication"
class Solver:
def demo(self):
while True:
a = int(input("a "))
b = int(input("b "))
c = int(input("c "))
d = b ** 2 - 4 * a * c
if d >= 0:
disc = math.sqrt(d)
root1 = (-b + disc) / (2 * a)
root2 = (-b - disc) / (2 * a)
print(root1, root2)
else:
print('error')
Solver().demo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment