Discuss / Python / 从ide直接粘贴过来了

从ide直接粘贴过来了

Topic source

浪过扬帆

#1 Created at ... [Delete] [Delete and Lock User]
def quadratic(a, b, c):    if not isinstance(a, (int, float)) or not isinstance(b, (int, float) or not isinstance(c, (int, float))):        raise TypeError('bad operand type')    mark = b ** 2 - 4 * a * c    if mark < 0:        print('方程无实根')        return    else:        x1 = (-1 * b + math.sqrt(mark)) / (2 * a)        x2 = (-1 * b - math.sqrt(mark)) / (2 * a)        return x1, x2

浪过扬帆

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

def quadratic(a, b, c):

if not isinstance(a, (int, float)) or not isinstance(b, (int, float) or not isinstance(c, (int, float))):
raise TypeError('bad operand type')
    mark = b ** 2 - 4 * a * c
if mark < 0:
        print('方程无实根')
        return
    else:
        x1 = (-1 * b + math.sqrt(mark)) / (2 * a)
        x2 = (-1 * b - math.sqrt(mark)) / (2 * a)
return x1, x2


  • 1

Reply