Last active
August 29, 2015 14:10
-
-
Save MishoG/6c7799e58c84b7a3212f to your computer and use it in GitHub Desktop.
კვადრატული განტოლების ამოხსნა / solving quadratic equation
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 | |
import os | |
import sys | |
def cls(): | |
os.system(['clear','cls'][os.name == 'nt']) | |
def quadratic(): | |
a = int(input('enter a: ')) | |
b = int(input('enter b: ')) | |
c = int(input('enter c: ')) | |
D = b**2-4*a*c | |
if D < 0: | |
print 'no solution' | |
elif D == 0: | |
print round((-b)/(2*a),2) | |
else: | |
print 'x1=' , round((-b+math.sqrt(D))/(2*a),2) | |
print 'x2=' , round(-b-math.sqrt(D))/(2*a) | |
menu() | |
def menu(): | |
print 'choose:\n start again - 1 \n quit - 2 ' | |
choice = int(input('choose')) | |
if choice == 1: | |
cls() | |
quadratic() | |
elif choice ==2: | |
sys.exit | |
quadratic() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment