Discuss / Python / 提交作业

提交作业

Topic source
在此插入代码
if a == 0:
    print('Error,a could not be equal to 0')
    return
elif b*b-4*a*c < 0:
    print('Error,b*b-4*a*c could not be less than 0')
    return 
elif b*b-4*a*c == 0:
    return -b/(2*a)
elif b*b-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

  • 1

Reply