望指教,谢谢
import math def quadratic_equation(a, b, c): x=b*b+4*a*c if a<0: return 'no root' else: x1=(-b+math.sqrt(x))/(2*a*) x2=(-b-math.sqrt(x))/(2*a*) return x1, x2 print quadratic_equation(2, 3, 0) print quadratic_equation(1, -6, 5)
import math def quadratic_equation(a, b, c): x=b*b+4*a*c if a<0: return 'no root' else: x1=(-b+math.sqrt(x))/(2*a*) x2=(-b-math.sqrt(x))/(2*a*) return x1, x2 print quadratic_equation(2, 3, 0) print quadratic_equation(1, -6, 5)
2017-06-07
举报