Skip to content

Instantly share code, notes, and snippets.

@MishoG
Last active August 29, 2015 14:10
Show Gist options
  • Save MishoG/6c7799e58c84b7a3212f to your computer and use it in GitHub Desktop.
Save MishoG/6c7799e58c84b7a3212f to your computer and use it in GitHub Desktop.
კვადრატული განტოლების ამოხსნა / solving quadratic equation
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