Discuss / Python / 2022-03-02作业

2022-03-02作业

Topic source

Simms_zh

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

    if not isinstance(a or b or c, (int, float)):

        raise TypeError('bad operand type')

    if a == 0:

        print("a不应等于0")

        raise TypeError('A value must not be 0')

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

    if n >= 0:

        x1 = (-b + math.sqrt(n)) / (2 * a)

        x2 = (-b - math.sqrt(n)) / (2 * a)

        return x1, x2

    elif n < 0:

        print("方程无实数解")


  • 1

Reply