交作业啦
Topic sourcedef quandratic(a,b,c):
x = (b**2)-(4*a*c)
if a == 0:
return -(c/b)
elif x >= 0:
x1 = (-(b)+math.sqrt(x))/(2*a)
x2 = (-(b)-math.sqrt(x))/(2*a)
return x1,x2
else:
return '该方程无解'
- 1
def quandratic(a,b,c):
x = (b**2)-(4*a*c)
if a == 0:
return -(c/b)
elif x >= 0:
x1 = (-(b)+math.sqrt(x))/(2*a)
x2 = (-(b)-math.sqrt(x))/(2*a)
return x1,x2
else:
return '该方程无解'
BillCode
import math
def quandratic(a,b,c): x = (b*2)-(4a*c)
print(quandratic(2,3,1)) print(quandratic(1, 3, -4))