小弟在编写一个一元二次方程求解的代码,遇到一些错误,还请大神们悉心指出,以举手之劳帮小弟一把,以下是一段代码:
import math
def quadratic(a,b,c):
p=float(b^2-4*a*c)
if p<0:
return 'wrong'
else:
x1=float((math.sqrt(p)-b)/2*a)
x2=float((math.sqrt(p)+b)/2*a)
return x1,x2
在Python显示平,p<0出现了“math domain error”,请问怎么编写
并烦劳各位大牛们指出还有什么错误
感激不尽!