Discuss / Python / 作业

作业

Topic source

MajorTomi

#1 Created at ... [Delete] [Delete and Lock User]

    for num in [a,b,c]:

        if not isinstance(num,(int,float)):

            raise TypeError('bad operand type')

    delta = b**2-4*a*c

    if delta < 0:

        print('没有实根')

    else:

        delta1 = math.sqrt(delta)

        x1 = ((-b)+delta1)/(2*a)

        x2 = ((-b)-delta1)/(2*a) 

        return x1, x2


  • 1

Reply