import math
def fun(a,b,c):
if b**2-4*a*c > 0:#判断方程有无实数解
x1=(-b+math.sqrt(b*b-4*a*c))/(2*a)
x2=(-b-math.sqrt(b*b-4*a*c))/(2*a)
return x1,x2
elif b**2-4*a*c == 0:
x = -b/(2*a)
return x
else:
return '该二元一次方程无实数根'
a = fun(1,4,3)#给fun()传参
print(a)
运行结果如下: