求一元二次方程的解

import math
while True:
a = float (raw_input('input a:'))
b = float (raw_input('input b:'))
c = float (raw_input('input c:'))
if a!=0:
delta=b**2-4*a*c
if delta<0:
print'NO solution'
elif delta==0:
s=-b/(2*a)
print s
else:
root=math.sqrt(delta)
s1=(-b+root)/(2*a)
s2=(-b-root)/(2*a)
print 'Two distinct solutions are:',s1,s2
ch=raw_input('quit?')
if ch=='q':
break

 

转载于:https://www.cnblogs.com/01csc/p/7249235.html

你可能感兴趣的:(求一元二次方程的解)