Created
February 18, 2015 14:19
-
-
Save ejmurray/2cf500d31cfe10a84ed9 to your computer and use it in GitHub Desktop.
solves the square root of a triangle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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