Discuss / Python / 交作业

交作业

Topic source
def quadratic(a, b, c):
    #数值检查
    for x in (a,b,c):
        if not isinstance(x,(int,float)):
            return None
    #除数非零检查
    if not a:
        return None
    else:
        delt_s=math.sqrt(b**2-4*a*c)
        return (-b+delt_s)/(2*a),(-b-delt_s)/(2*a)

  • 1

Reply